brickyang / egg-mongo-native

MongoDB egg.js plugin using native driver.
MIT License
75 stars 11 forks source link

Error when insertOne new data #18

Closed WynnLin closed 6 years ago

WynnLin commented 6 years ago

Here is my config exports.mongo = { client: { host: '127.0.0.1', port: '27017', name: 'test', user: 'root', password: 'root', options: {} } }; and I use it like app.mongo.insertOne('name', '123123');

for my mongoDB I have a database = test in the test database i have a collection which named test also image

the error is show when i call app.mongo.insertOne('name', '123123'); 2018-09-18 15:15:24,693 ERROR 44536 nodejs.TypeError: Cannot read property '_id' of undefined

Is that clear for my issue

brickyang commented 6 years ago

app.mongo.insertOne('test', { doc: { name: '123123' } }) app.mongo.find('test', { query: { name: 'test' } })

WynnLin commented 6 years ago

app.mongo.insertOne('test', { doc: { name: '123123' } }) app.mongo.find('test', { query: { name: 'test' } })

sorry for my first use, so doc or query are keywords?

brickyang commented 6 years ago

https://github.com/brickyang/egg-mongo-native#example