You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by "john.tiger" <jo...@gmail.com> on 2011/11/07 17:53:37 UTC

nodejs couchapp

The node.couchapp.js module seems so much cleaner/simpler than the 
python based couchapp tools but we are having trouble since there is not 
much documentation or tutorials yet.

$node ./lib/bin.js -s testapp.js http://127.0.0.1:5984/testapp

this runs without error but no response message and nothing shows up in 
Futon

testapp.js
var node_couchapp = require("./lib/node-couchapp"); //we renamed main.js
var ddoc = {_id:'_design/app', shows:{}};
exports.app = ddoc;
ddoc.shows.foo = function (doc, req) {
   return "<h1>Test App</h1><p>So Much</p>";
};

in the blog by Chris Strom he used a command line like:
$node ./lib/bin.js -s -d testapp.js -c http://127.0.0.1:5984/testapp

when we tried this - got errors with "-d" and "-c"

I have no idea what the "-s" "-d" or "-c" command operators do

can anyone help on this - thks


Re: nodejs couchapp

Posted by Sean Copenhaver <se...@gmail.com>.
Just read this thread, thought I would throw out a few thoughts.

It would be great to see some best practices for medium and large scale (as
in size and complexity) applications utilizing CouchDB. I do not have any
so the next section is speculation.

I feel like the evolution of a CouchApp is something like:

   1. Basic CouchApp, CouchDB providing data as a service and app hosting
   with a browser running thick client JavaScript. Can be super fast to get
   going.
   2. Need a little more control over CouchDB interaction, auth/auth, or
   output and add a thin web layer using something like node.js's Express or
   Ruby's Sinatra.
   3. Need external services to react to system events being published
   through CouchDB (could be from the client or replication if in a
   distributed system). Also provides a means for system to system
   integrations.


You could go from 1 to 3 then add 2, but I feel like this is a situation
where CouchDB shines with it's replicator db and _changes feed. Gives you
an event driven system where things are reactive. I feel like CouchDB is
best when it's a centerpiece or right out in front. Plus since you could be
in a disconnected or high latency (mobile or just flaky wifi) situation
this model could provide a responsive UI wen you rely on publishing an
event and notifying the user when there are changes.

I'll admit this doesn't fit all apps, but you could use CouchDB's proxy
feature to delegate out to services for sync' behavior or use 2.


Does anyone have experience or thoughts on the matter?


On Tue, Nov 8, 2011 at 1:37 PM, Ryan Ramage <ry...@gmail.com> wrote:

> > Sometimes it's easy to forget how much of building couchapps is simple
> because CouchDB is simple, and writing an app in node.js with CouchDB as a
> datastore is still quite simple even if it's a little more complicated than
> a couchapp and as you start doing those backflips it might be simpler to
> break out of the couchapp model and keep CouchDB as a backend store.
> >
>
> I totally agree. But I think most developers tend to try and find the
> biggest box to use. So when they look at couchapps they go hmm, nope,
> not going to try, not a big enough box.
>
> What might be useful to explore is some docs/best practices for
> growing your app out of the couchapp box. "How should I migirate
> assets into a node front end?", "What about auth", etc. That way
> people can feel comfortable starting with couchapps knowing they can
> move upwards if needed.
>
> Maybe I have not investigated if such resources exist, but it might be
> useful for the various couchapp communities to provide.
>
> Ryan
>



-- 
“The limits of language are the limits of one's world. “ - Ludwig von
Wittgenstein

"Water is fluid, soft and yielding. But water will wear away rock, which is
rigid and cannot yield. As a rule, whatever is fluid, soft and yielding
will overcome whatever is rigid and hard. This is another paradox: what is
soft is strong." - Lao-Tzu

Re: nodejs couchapp

Posted by Ryan Ramage <ry...@gmail.com>.
> Sometimes it's easy to forget how much of building couchapps is simple because CouchDB is simple, and writing an app in node.js with CouchDB as a datastore is still quite simple even if it's a little more complicated than a couchapp and as you start doing those backflips it might be simpler to break out of the couchapp model and keep CouchDB as a backend store.
>

I totally agree. But I think most developers tend to try and find the
biggest box to use. So when they look at couchapps they go hmm, nope,
not going to try, not a big enough box.

What might be useful to explore is some docs/best practices for
growing your app out of the couchapp box. "How should I migirate
assets into a node front end?", "What about auth", etc. That way
people can feel comfortable starting with couchapps knowing they can
move upwards if needed.

Maybe I have not investigated if such resources exist, but it might be
useful for the various couchapp communities to provide.

Ryan

Re: nodejs couchapp

Posted by Mikeal Rogers <mi...@gmail.com>.
On Nov 8, 2011, at November 8, 20119:41 AM, Ryan Ramage wrote:

> If you want a feel where you can go with couchapps, checkout Max
> Ogden's datacouch project:
> 
> https://github.com/maxogden/datacouch
> 
> While not purely couchapp, it shows the way on how to move past the
> boundaries of the traditional couchapp model.
> 
> While Mikeal may be tired of doing backflips, I don't mind. The first
> couple of backflips you might hit your head, but then they become easy
> and you might find them invigorating as well. :)

It's a tradeoff. Sometimes it's worth the backflips. For some use cases you have no choice, writing an offline app you have many of the same constraints so you might as well write offline apps as couchapps.

Sometimes it's easy to forget how much of building couchapps is simple because CouchDB is simple, and writing an app in node.js with CouchDB as a datastore is still quite simple even if it's a little more complicated than a couchapp and as you start doing those backflips it might be simpler to break out of the couchapp model and keep CouchDB as a backend store.

-Mikeal

> 
> Ryan
> 
> On Tue, Nov 8, 2011 at 10:02 AM, Mikeal Rogers <mi...@gmail.com> wrote:
>> 
>> 
>> On Nov 8, 2011, at November 8, 20118:47 AM, john.tiger wrote:
>> 
>>> On 11/07/11 15:14, Mikeal Rogers wrote:
>>>> I wrote node-couchapp and i don't even remember what those flags did. i have since changed the command line api.
>>>> 
>>>> couchapp push app.jshttp://localhost:5984/db
>>> 
>>> Thks.  Wow, this is so simple and works great.
>>> 
>>> Now a question:  since making a couch app is so easy, why are not more people using it ?  Are couch apps limited versus using a full MVC backend (ie Express, Strata, ..)
>> 
>> There are definitely limitations, pulling info in to the page that isn't in your database isn't doable, _list and _show are pretty slow so you're limited to single page apps if you want to keep things really fast.
>> 
>> For simple things, nothing is simpler than a couchapp, but as your app gets more complex you're going to start doing backflips to get it to fit in to the couchapp model.
>> 
>> -Mikeal


Re: nodejs couchapp

Posted by Ryan Ramage <ry...@gmail.com>.
If you want a feel where you can go with couchapps, checkout Max
Ogden's datacouch project:

https://github.com/maxogden/datacouch

While not purely couchapp, it shows the way on how to move past the
boundaries of the traditional couchapp model.

While Mikeal may be tired of doing backflips, I don't mind. The first
couple of backflips you might hit your head, but then they become easy
and you might find them invigorating as well. :)

Ryan

On Tue, Nov 8, 2011 at 10:02 AM, Mikeal Rogers <mi...@gmail.com> wrote:
>
>
> On Nov 8, 2011, at November 8, 20118:47 AM, john.tiger wrote:
>
>> On 11/07/11 15:14, Mikeal Rogers wrote:
>>> I wrote node-couchapp and i don't even remember what those flags did. i have since changed the command line api.
>>>
>>> couchapp push app.jshttp://localhost:5984/db
>>
>> Thks.  Wow, this is so simple and works great.
>>
>> Now a question:  since making a couch app is so easy, why are not more people using it ?  Are couch apps limited versus using a full MVC backend (ie Express, Strata, ..)
>
> There are definitely limitations, pulling info in to the page that isn't in your database isn't doable, _list and _show are pretty slow so you're limited to single page apps if you want to keep things really fast.
>
> For simple things, nothing is simpler than a couchapp, but as your app gets more complex you're going to start doing backflips to get it to fit in to the couchapp model.
>
> -Mikeal

Re: nodejs couchapp

Posted by Mikeal Rogers <mi...@gmail.com>.

On Nov 8, 2011, at November 8, 20118:47 AM, john.tiger wrote:

> On 11/07/11 15:14, Mikeal Rogers wrote:
>> I wrote node-couchapp and i don't even remember what those flags did. i have since changed the command line api.
>> 
>> couchapp push app.jshttp://localhost:5984/db
> 
> Thks.  Wow, this is so simple and works great.
> 
> Now a question:  since making a couch app is so easy, why are not more people using it ?  Are couch apps limited versus using a full MVC backend (ie Express, Strata, ..)

There are definitely limitations, pulling info in to the page that isn't in your database isn't doable, _list and _show are pretty slow so you're limited to single page apps if you want to keep things really fast. 

For simple things, nothing is simpler than a couchapp, but as your app gets more complex you're going to start doing backflips to get it to fit in to the couchapp model.

-Mikeal

Re: nodejs couchapp

Posted by "john.tiger" <jo...@gmail.com>.
On 11/07/11 15:14, Mikeal Rogers wrote:
> I wrote node-couchapp and i don't even remember what those flags did. i have since changed the command line api.
>
> couchapp push app.jshttp://localhost:5984/db

Thks.  Wow, this is so simple and works great.

Now a question:  since making a couch app is so easy, why are not more 
people using it ?  Are couch apps limited versus using a full MVC 
backend (ie Express, Strata, ..)




Re: nodejs couchapp

Posted by Mikeal Rogers <mi...@gmail.com>.
I wrote node-couchapp and i don't even remember what those flags did. i have since changed the command line api.

couchapp push app.js http://localhost:5984/db

or

couchapp sync app.js http://localhost:5984/bd

if you do

npm install -g couchapp

the couchapp bin should be in your $PATH

-Mikeal

On Nov 7, 2011, at November 7, 20118:53 AM, john.tiger wrote:

> The node.couchapp.js module seems so much cleaner/simpler than the python based couchapp tools but we are having trouble since there is not much documentation or tutorials yet.
> 
> $node ./lib/bin.js -s testapp.js http://127.0.0.1:5984/testapp
> 
> this runs without error but no response message and nothing shows up in Futon
> 
> testapp.js
> var node_couchapp = require("./lib/node-couchapp"); //we renamed main.js
> var ddoc = {_id:'_design/app', shows:{}};
> exports.app = ddoc;
> ddoc.shows.foo = function (doc, req) {
>  return "<h1>Test App</h1><p>So Much</p>";
> };
> 
> in the blog by Chris Strom he used a command line like:
> $node ./lib/bin.js -s -d testapp.js -c http://127.0.0.1:5984/testapp
> 
> when we tried this - got errors with "-d" and "-c"
> 
> I have no idea what the "-s" "-d" or "-c" command operators do
> 
> can anyone help on this - thks
>