1602 / 1602/jugglingdb

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

Abierto
#392 0 comentarios 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
JavaScript
Estrellas
2k
Forks
238
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

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. (/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. (/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?

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.