Best Available options to use : mongodb with node.js

677 views
Skip to first unread message

Sumit

unread,
Feb 9, 2011, 9:36:36 PM2/9/11
to nodejs
Guys

I am trying to use mongodb with node.js , Is there anyone who
experienced with the same ? and suggest node.js based native driver or
whatever ( I have almost no knowledge about mongodb, but yes I
installed node.js on my system and ran/write few small examples).

From Internet sources one options seems to be good is : mongoose
My purpose is to implement Proxy cache via using node.js

Though several coded-modules exist from this link, :
https://github.com/ry/node/wiki/modules still I want to hear your
experience.

/Sumit

Andrew Brookins

unread,
Feb 10, 2011, 12:09:04 AM2/10/11
to nod...@googlegroups.com
> --
> You received this message because you are subscribed to the Google Groups "nodejs" group.
> To post to this group, send email to nod...@googlegroups.com.
> To unsubscribe from this group, send email to nodejs+un...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/nodejs?hl=en.
>
>

I've been working with mongoose for a couple of weeks. It's not bad -
I've only used the most basic features, though, like schema definition
and validation.

I have run into a few puzzling error messages. In particular when you
try to create a model instance that includes a field you didn't define
in the schema for the model. But nothing too hard to puzzle out.

Also, I encountered one bug (which I don't remember), but the
maintainer released a fix within 24 hours.

Andrew

Sumit

unread,
Feb 10, 2011, 2:20:03 AM2/10/11
to nodejs
Its a good input for me!! that others are also using mongoose !!

On Feb 10, 2:09 pm, Andrew Brookins <a.m.brook...@gmail.com> wrote:
> On Wed, Feb 9, 2011 at 6:36 PM, Sumit <sumit1...@gmail.com> wrote:
> > Guys
>
> > I am trying to use mongodb with node.js , Is there anyone who
> > experienced with the same ? and suggest node.js based native driver or
> > whatever ( I have almost no knowledge about mongodb, but yes I
> > installed node.js on my system and ran/write few small examples).
>
> > From Internet sources one options seems to be good is : mongoose
> > My purpose is to implement Proxy cache via using node.js
>
> > Though several coded-modules exist from this link, :
> >https://github.com/ry/node/wiki/modulesstill I want to hear your
> > experience.
>
> > /Sumit
>
> > --
> > You received this message because you are subscribed to the Google Groups "nodejs" group.
> > To post to this group, send email to nod...@googlegroups.com.
> > To unsubscribe from this group, send email to nodejs+un...@googlegroups.com.
> > For more options, visit this group athttp://groups.google.com/group/nodejs?hl=en.

Peter Hewat

unread,
Feb 10, 2011, 3:28:43 AM2/10/11
to nod...@googlegroups.com
Hi, you might be interested in joining the mongoose google groups:

john tigernassau

unread,
Feb 10, 2011, 1:50:08 PM2/10/11
to nod...@googlegroups.com

We work with the node-mongo-driver.  It works well and was recommended by the 10gen folks.  If you want a more object structured framework then Mongoose seems interesting but document (json format) oriented nosql allows you to use a db differntly and we find less of a need to convert our data into object classes.

On Feb 10, 2011 12:20 AM, "Sumit" <sumi...@gmail.com> wrote:

Its a good input for me!! that others are also using mongoose !!

On Feb 10, 2:09 pm, Andrew Brookins <a.m.brook...@gmail.com> wrote:

> On Wed, Feb 9, 2011 at 6:36 PM, Sumit <sumit1...@gmail.com> wrote:
> > Guys
>

> > I am trying to u...

> > experience.
>
> > /Sumit
>
> > --
> > You received this message because you are subscribed to th...

> > For more options, visit this group athttp://groups.google.com/group/nodejs?hl=en.

>
> I've been working with mongoose for a couple of weeks. It's not bad -

> I've only used the most ...

Laurie Harper

unread,
Feb 10, 2011, 5:46:15 PM2/10/11
to nod...@googlegroups.com
Mongoose is a good option if you like it's API and document model; if you want something lower-level and closer to the MongoDB shell / native API, try mongodb-native (https://github.com/christkv/node-mongodb-native).

L.

--
You received this message because you are subscribed to the Google Groups "nodejs" group.
To post to this group, send email to nod...@googlegroups.com.
To unsubscribe from this group, send email to nodejs+un...@googlegroups.com.

Kilian C.

unread,
Feb 11, 2011, 8:57:13 AM2/11/11
to nod...@googlegroups.com
+1

Aurélio A. Heckert

unread,
Feb 10, 2011, 1:59:35 PM2/10/11
to nod...@googlegroups.com
On 2/9/11, Sumit <sumi...@gmail.com> wrote:
> Guys
>
> I am trying to use mongodb with node.js , Is there anyone who
> experienced with the same ? and suggest node.js based native driver or
> whatever ( I have almost no knowledge about mongodb, but yes I
> installed node.js on my system and ran/write few small examples).
>
> From Internet sources one options seems to be good is : mongoose
> My purpose is to implement Proxy cache via using node.js

I have started a project using mongodb, but i see that was a big wrong
choice. I must have to use mongoose from the start, because i was
recreating all common tasks by myself. Change all to mongoose was
more easy than maintains as that was.

mongodb is good, but use only if you need a more low level db usage
or/and less control to the data.

--
Aurélio A. Heckert http://SoftwareLivre.org/aurium
Coop. de Tecnologias Livres: http://Colivre.coop.br
- - - - - - - - - - - - - - - - - - - - - - - - -
GNU/Linux User #312507 http://counter.li.org
Ilustração Vetorial Livre: http://InkscapeBrasil.org
- - - - - - - - - - - - - - - - - - - - - - - - -
"Windows 7: a new era of restrictions."
http://windows7sins.org

Antes de imprimir esta mensagem reflita
sobre a sua responsabilidade com a
preservação do Meio Ambiente.

Sidney Lima Filho

unread,
Feb 11, 2011, 9:52:24 AM2/11/11
to nod...@googlegroups.com
+2

Atenciosamente    
                                                                         
Sidney Lima Filho
Vivina Softhouse
http://vivina.com.br | @sidneyfilho

Sumit Arora

unread,
Feb 14, 2011, 7:01:17 AM2/14/11
to nod...@googlegroups.com
I studied all across the mongoose, and referred many examples around, still I wasn't able to compile or execute any simple example , as per the documentation it , Please see below and provide you comments, It will be great if you can please send me any example


I have tried a lot to compile even one basic example of mongoose but
didn't get any success, --

See below :

Mongoose Version : 1.0.10
node version : v0.3.7



Files : ex5.js and schema.js are in same directory
=======================================

Received Error :

node.js:116
       throw e; // process.nextTick error, or 'error' event on first
tick
       ^
Error: Schema hasn't been registered for model "./schema.js".
Use Mongoose.define(name, schema)

   at Mongoose.model (/usr/local/lib/node/.npm/mongoose/1.0.10/
package/lib/mongoose/index.js:138:13)
   at Object.<anonymous> (/home/esumit/mongodb/examples/model/ex5.js:
7:24)
   at Module._compile (module.js:287:26)
   at Object..js (module.js:293:10)
   at Module.load (module.js:219:31)
   at Function._load (module.js:186:10)
   at Array.<anonymous> (module.js:307:10)
   at EventEmitter._tickCallback (node.js:108:26)

Or

----------
If I use var myModel = mongoose.model('BlogPost');
------
node.js:116
       throw e; // process.nextTick error, or 'error' event on first
tick
       ^
Error: Schema hasn't been registered for model "BlogPost".
Use Mongoose.define(name, schema)

   at Mongoose.model (/usr/local/lib/node/.npm/mongoose/1.0.10/
package/lib/mongoose/index.js:138:13)
   at Object.<anonymous> (/home/esumit/mongodb/examples/model/ex5.js:
7:24)
   at Module._compile (module.js:287:26)
   at Object..js (module.js:293:10)
   at Module.load (module.js:219:31)
   at Function._load (module.js:186:10)
   at Array.<anonymous> (module.js:307:10)
   at EventEmitter._tickCallback (node.js:108:26)


-------------------------------------------------------------------
File-Name : ex5.js  Contents
==================================
var mongoose = require('mongoose');


mongoose.connect('mongodb://localhost:27017/test');

var myModel = mongoose.model('./schema.js');

---------------------------------------------------------------------------------
File Name : schema.js Contents
==================================

/**
 * Pre hook.
 */

BlogPost.pre('save', function(next, done){
 emailAuthor(done); // some async function
 next();
});

/**
 * Plugins
 */

function slugGenerator (options){
 options = options || {};
 var key = options.key || 'title';

 return function slugGenerator(schema){
   schema.path(key).set(function(v){
     this.slug = v.toLowerCase().replace(/[^a-z0-9]/g, '').replace(/-
+/g, '');
     return v;
   });
 };
};

BlogPost.plugin(slugGenerator());

/**
 * Define model.
 */

mongoose.model('BlogPost', BlogPost);
------------------------------------------------------------------------------------------------------------------

Is there any one who can please share your experience on this ? I
tried to use several permutation and combination to compile at-least
one scenario but didn't get success.

Pau

unread,
Feb 22, 2011, 3:30:38 AM2/22/11
to nod...@googlegroups.com
I'm the author of mongolia, the non-ORM alternative to use the raw mongodb driver.

Mongolia is just a little wrapper around the driver that eases the pain of dealing some operations.

IMHO, having models with data and logic mixed up (the activerecord way) is harder to mantain/test as functions have to deal with side effects. Using mongolia you just define functions and hooks that receive mongodb documents and do something with them.

Let's say, mongoose is OOP oriented, and mongolia is FP oriented... kind of.

The module is well documented, but to be honest.. still missing lots of tests which will come with the 1.0 branch I'm working on. The comunity around mongolia is still non-existant (I'm not a rockstar/guru/ninja/... so when my modules are released nobody notices it) although I hope this will change in the future.

shaun etherton

unread,
Feb 22, 2011, 5:22:05 AM2/22/11
to nod...@googlegroups.com
 I dig your stuff man. Keep up the good work. 
 
- shaun


Floby

unread,
Feb 23, 2011, 5:06:35 AM2/23/11
to nodejs
I used Mongoose before the major update. haven't tried it since. but i
worked fine as long as you stayed within the basics. If you want
something fancy, try the native mongodb driver or mongolia.
> Though several coded-modules exist from this link, :https://github.com/ry/node/wiki/modulesstill I want to hear your
> experience.
>
> /Sumit
Reply all
Reply to author
Forward
0 new messages