Geddy 0.5 & MongoDB

100 views
Skip to first unread message

Gerard Nesta

unread,
Oct 27, 2012, 3:49:31 PM10/27/12
to ged...@googlegroups.com
GeddyVersion: 0.5.5
NodeVersion: 0.8.12

Issue(s) - be specific/include console debugs:
[Sat, 27 Oct 2012 19:32:54 GMT] ERROR model is not defined
ReferenceError: model is not defined
    at utils
.mixin.update (C:\Users\gerardnll\AppData\Roaming\npm\node_modules\g
eddy
\node_modules\model\lib\adapters\mongo\index.js:240:31)
    at exports
.Collection.self.update (C:\nodejs_tests\immo\node_modules\mongodb
-wrapper\lib\mongodb-wrapper.js:376:17)
    at
Collection.update (C:\nodejs_tests\immo\node_modules\mongodb-wrapper\node
_modules
\mongodb\lib\mongodb\collection.js:442:12)
    at exports
.Collection.self.update (C:\nodejs_tests\immo\node_modules\mongodb
-wrapper\lib\mongodb-wrapper.js:374:24)
    at exports
.Collection.self.ensureIndex.cb (C:\nodejs_tests\immo\node_modules
\mongodb-wrapper\lib\mongodb-wrapper.js:201:17)
    at
Db.collection (C:\nodejs_tests\immo\node_modules\mongodb-wrapper\node_mod
ules
\mongodb\lib\mongodb\db.js:449:44)
    at exports
.Collection.self.ensureIndex.cb (C:\nodejs_tests\immo\node_modules
\mongodb-wrapper\lib\mongodb-wrapper.js:193:16)
    at exports
.Database.self.connection (C:\nodejs_tests\immo\node_modules\mongo
db
-wrapper\lib\mongodb-wrapper.js:615:20)
    at connection
(C:\nodejs_tests\immo\node_modules\mongodb-wrapper\lib\mongodb
-wrapper.js:190:18)
    at exports
.Collection.self.update (C:\nodejs_tests\immo\node_modules\mongodb
-wrapper\lib\mongodb-wrapper.js:371:9)

Hi Guys, i'm new here and I am already asking things :) Maybe it's just a noob question but i hope you understand me because i'm just starting with nodeJS.

Ok, first. I've done a new app and i've run the console command to make a new scaffold following the todo tutorial.
Now i want to use mongodb to make info persistent. i've mongod running, mongodb-wrapper installed locally (also geddy, apart from globally) and in production.js i've taken out the commented lines to have it set for mongo.
What happens is that, i can create new todos, edit them, list them, and delete them. but when clicking "save" or "add" the console outputs the error above and doesn't redirect although it has executed the commands.

i thought that with the ORM layer geddy uses it was as simple as that. Does it still works as explained on this famous tut?

Thank you very much guys, hope to make something cool with your fantastic framework. :D

Matthew Eernisse

unread,
Oct 27, 2012, 6:57:56 PM10/27/12
to ged...@googlegroups.com
The newest version of Geddy (0.5) has some changes, so that tutorial is a bit out of date.

Here's the current tutorial:

http://geddyjs.org/tutorial

Let us know how it goes!

--
The official community discussion group.
website: geddyjs.org, source: https://github.com/mde/geddy, group: https://groups.google.com/d/forum/geddyjs?hl=en
 
 

Gerard Nesta

unread,
Oct 28, 2012, 6:53:51 AM10/28/12
to ged...@googlegroups.com
Yes, i've been following that tutorial, but i still get that Error saying that "model is not defined". Works fine while working with memory for persistence but not when changing to mongodb (mongodb-wrapper).


Thanks!

mistermojo

unread,
Oct 28, 2012, 11:40:38 AM10/28/12
to ged...@googlegroups.com

Hi all,

I'm afraid I can confirm this problem. This is what I did (no editing of generated stuff except config):
1. upgraded to geddy 0.5.5
2. created a new geddy app
3. created a scaffold (called todoItem) with 3 properties
4. ran the geddy app

With geddy using the memory adapter it all works fine. Listing, viewing, creating, editing, deleting works fine. No errors.


When I changed config in development.js to mongo
"""
/*
, model: {
    defaultAdapter: 'memory'
    }
*/

, model: {
    defaultAdapter: 'mongo'
    }
, db: {
    mongo: {
      dbname: 'anothertodo'
    }
  }
"""

0. npm installed a fresh mongodb-wrapper

1. listing works
2. creating an item kills the worker
"""
/home/dev/GeddyJS/anothertest/node_modules/mongodb-wrapper/node_modules/mongodb/lib/mongodb/connection/server.js:359
        throw err;
              ^

ReferenceError: model is not defined
"""

but curiously the item is created and can be verified with a geddy restart

3. viewing the edit page for the item works.
4. removing the item works (without errors)
5. editing and saving kills the worker with error:
"""
/usr/lib/node_modules/geddy/node_modules/model/lib/adapters/mongo/index.js:240
          if (data instanceof model.ModelBase) {
                              ^

ReferenceError: model is not defined
"""
6. restarting geddy shows that actually, the save works.

I am afraid I don't know geddy well enough to pin-point the problem. Creating and updating items in with mongo kills the worker and the app hangs but apparently, *after* doing the writing to db. Very curious. Did not have this problem before when I was still using 0.5.2 (and possibly older mongodb-wrapper)

Could it be some weird incompatibility with a new mongodb-wrapper? I don't know what version I had before, though.

Sorry for the long post. Thanks for your time.

Gerard Nesta

unread,
Oct 28, 2012, 11:53:23 AM10/28/12
to ged...@googlegroups.com
Yes that's exactly the proceeding, or the little bit different one from the tutorial.

Let's see if some one can figure this out... Thanks.

Gerard Nesta

unread,
Oct 29, 2012, 3:53:44 PM10/29/12
to ged...@googlegroups.com
Well i've got news about this. 
I am on Windows 7 x64 and a friend of mine tried my app on a Mac, and he got it to work.
So it must be something about the OS.
yeah, i know i should be using MacOS or Linux...

thanks.

Matthew Eernisse

unread,
Oct 29, 2012, 3:56:32 PM10/29/12
to ged...@googlegroups.com
No, there was a real bug in the MongoDB adapter for JS Model. It has been fixed and published to NPM. Please update Geddy ("npm update -g geddy") and try on Windows. Things should work fine now.


Matthew

Gerardnll

unread,
Oct 29, 2012, 4:01:41 PM10/29/12
to ged...@googlegroups.com
Yes! Working fine now!

Thanks a lot Matthew :D

2012/10/29 Matthew Eernisse <m...@fleegix.org>
Reply all
Reply to author
Forward
Message has been deleted
0 new messages