Comments (6)
Thanks for opening an issue. Do you mean it should return an array or that it does and the docs are wrong?
from hapi-mongo-models.
I would imagine, .insertOne() would return an object (without an nesting array).
I get:
result = [ {foo:1} ]
expected:
result = {foo:1}
I base this upon .findOne() or .findById() does indeed only return an object (without the nesting array).
from hapi-mongo-models.
Ah yes, I remember this. We're simply proxying the call to the driver's insertOne
method:
hapi-mongo-models/lib/base-model.js
Line 439 in 11fa7a6
According to the docs:
http://mongodb.github.io/node-mongodb-native/2.0/api/Collection.html#insertOne
insertOne
has a writeOpCallback
callback:
http://mongodb.github.io/node-mongodb-native/2.0/api/Collection.html#~writeOpCallback
Which defines the result as a WriteOpResult
http://mongodb.github.io/node-mongodb-native/2.0/api/Collection.html#~WriteOpResult
If we chose to change this, it would be a major version bump as the API would change. Is it really worth it?
from hapi-mongo-models.
I'm new to Mongo, so not really in any position to advise on what is worth it.
I just believed to have discovered an Inconsistency error, but being an artifact from the driver, it might be outside your domain.
Appreciate your framework and your kind support, I hope its not to much trouble too ask.
from hapi-mongo-models.
I just believed to have discovered an Inconsistency error, but being an artifact from the driver, it might be outside your domain.
We could change it in this library, but I prefer to do as little as possible in that regard.
Appreciate your framework and your kind support, I hope its not to much trouble too ask.
That's always nice to hear. Thanks :) Always feel free to ask questions.
from hapi-mongo-models.
Model.insertOne() - Workaround to output an object, instead of array with an object
Model.insertOne( schema, function( err, model ){
if( err ) return reply( err );
return reply( model.shift() );
});
from hapi-mongo-models.
Related Issues (20)
- Can't use Mongo Native method Aggregate HOT 3
- Not authorized on dbname to execute command HOT 1
- QUESTION: Does this plug-in support associations? HOT 2
- Issue with updateOne & update Many HOT 4
- server.start() to include Mongo models? HOT 3
- v6.0.0 release notes
- Add a modelsDirectory plugin option
- using aggregate function HOT 2
- Not expected results in v6.0.0 responses HOT 3
- Multiple db support HOT 1
- MongoDB custom logger HOT 1
- Unable to get the instantiated db reference. HOT 1
- Hapi v17 support HOT 1
- Migrate callbacks pattern to async/await (hapi v17)
- Support for ssh tunnel ? HOT 6
- models "path/to/customer" might be off? HOT 2
- Migration help HOT 1
- Plugin example for 7.x.x? HOT 3
- $elemMatch returns all subjects HOT 1
- If connection.db is optional, why is there an assertion error if it isn't provided? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hapi-mongo-models.