1602 / 1602/compound

error in function create using scaffold with mongodb

Offen
#619 3 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
JavaScript
Sterne
1.6k
Forks
179
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

i'm trying to create a scaffold application with mongodb, like this:

```
compound init project --db mongodb
cd project
npm install
compound g scaffold person name
```

then i create a new person at localhost:3000/people/new
when i save the person i get the following error:

```
../node_modules/jugglingdb-mongodb/node_modules/mongodb/lib/mongodb/connection/base.js:245
throw message;
^
TypeError: Cannot read property '0' of null
at /project/node_modules/jugglingdb-mongodb/lib/mongodb.js:122:37
at /project/node_modules/jugglingdb-mongodb/node_modules/mongodb/lib/mongodb/collection/core.js:102:73
at /project/node_modules/jugglingdb-mongodb/node_modules/mongodb/lib/mongodb/db.js:1129:7
at /project/node_modules/jugglingdb-mongodb/node_modules/mongodb/lib/mongodb/db.js:1843:9
at Server.Base._callHandler (/project/node_modules/jugglingdb-mongodb/node_modules/mongodb/lib/mongodb/connection/base.js:445:41)
at /project/node_modules/jugglingdb-mongodb/node_modules/mongodb/lib/mongodb/connection/server.js:468:18
at MongoReply.parseBody (/project/node_modules/jugglingdb-mongodb/node_modules/mongodb/lib/mongodb/responses/mongo_reply.js:68:5)
at null. (/project/node_modules/jugglingdb-mongodb/node_modules/mongodb/lib/mongodb/connection/server.js:426:20)
at EventEmitter.emit (events.js:95:17)
at null. (/project/node_modules/jugglingdb-mongodb/node_modules/mongodb/lib/mongodb/connection/connection_pool.js:201:13)
at EventEmitter.emit (events.js:98:17)
at Socket. (/project/node_modules/jugglingdb-mongodb/node_modules/mongodb/lib/mongodb/connection/connection.js:422:22)
at Socket.EventEmitter.emit (events.js:95:17)
at Socket. (_stream_readable.js:746:14)
at Socket.EventEmitter.emit (events.js:92:17)
at emitReadable_ (_stream_readable.js:408:10)
at emitReadable (_stream_readable.js:404:5)
at readableAddChunk (_stream_readable.js:165:9)
at Socket.Readable.push (_stream_readable.js:127:10)
at TCP.onread (net.js:528:21)
```

in my database the person was saved, but with "id" null:

```
{
"_id" : ObjectId("534fc9cbc1bb90b475a6bd82"),
"name" : "teste",
"id" : null
}
```

I'm using mongodb 2.6.0, ubuntu 13.04 and jugglingdb 0.2.13

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Rechercherichtung

The error occurs in jugglingdb-mongodb at line 122, where it tries to access property '0' of null. The issue is that the scaffold saves a record with an 'id' field set to null. Start by examining the jugglingdb-mongodb adapter's create method and how it handles ID generation for MongoDB. Check the compound scaffold generation code to see how it sets up models with MongoDB. Look at the saved document structure and compare with expected schema. Run the scaffold steps locally to reproduce the error, then trace through the save flow.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
javascript, mongodb, nodejs
Bereich
backend, databases
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.