Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught exception TypeError, Object.keys called on non-object #392

Open
joeltello opened this issue Apr 5, 2014 · 0 comments
Open

Uncaught exception TypeError, Object.keys called on non-object #392

joeltello opened this issue Apr 5, 2014 · 0 comments

Comments

@joeltello
Copy link

I am trying to set up this module in my project using the nano-adapter. I am trying to save a document in this way:

Schema = require('jugglingdb').Schema
schema = new Schema 'nano', { ###config goes here### }
# creating model
User = schema.define 'User',
  prop: String
# saving instance
user = User()
user.prop = "testing"
user.save (err, result) ->
    console.log "Err", err
    console.log "Res", result  

it does save the document in the DB correctly but throws this exception:

error: Uncaught exception: __chain__=false, __wrapped__=[__chain__=false, name=TypeError, message=Object.keys called on non-object, stack=TypeError: Object.keys called on non-object
    at Function.keys (native)
    at Function.AbstractClass._fromDB (/myproject/node_modules/jugglingdb/lib/model.js:202:28)
    at /myproject/node_modules/jugglingdb/lib/model.js:317:37
    at /myproject/node_modules/jugglingdb-nano/lib/nano.js:105:16
    at Request._callback (/myproject/node_modules/jugglingdb-nano/node_modules/nano/nano.js:288:11)
    at Request.self.callback (/myproject/node_modules/jugglingdb-nano/node_modules/nano/node_modules/request/request.js:129:22)
    at Request.EventEmitter.emit (events.js:98:17)
    at Request.<anonymous> (/myproject/node_modules/jugglingdb-nano/node_modules/nano/node_modules/request/request.js:873:14)
    at Request.EventEmitter.emit (events.js:117:20)
    at IncomingMessage.<anonymous> (/myproject/node_modules/jugglingdb-nano/node_modules/nano/node_modules/request/request.js:824:12)]

I see that inside model.js(317) you have this:

if (rev) {
  rev = Model._fromDB(rev);
  obj._rev = rev
}

Model._fromDB implementation

AbstractClass._fromDB = function (data) {
    if (!data) return;
    var definition = this.schema.definitions[this.modelName].properties;
    var propNames = Object.keys(data);
...

Obviously data in this case is the revision number which is a string not an object.

Am I missing something? Is this bug related to the nano-adapter?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant