Comments (7)
Yes, we can check for the index, and I do think we should throw if there isn't one. Adding the index should be required, otherwise it's not actually an id field. I'll put together a PR.
from feathers-mongodb.
I was just replying and then @marshallswain beat me to it.
We changed the adapters from doing all the connection and collection setup stuff themselves to just passing the initialized collection. I agree that it makes sense to have the user do it but we should mention it in the docs. Is there maybe also a way to check if there is a unique index on the passed id field and throw a warning?
from feathers-mongodb.
I don't think the adapter should create indexes or unique rules, but it would be nice of us to mention how to do it in the docs.
from feathers-mongodb.
So this becomes really difficult due to the trickery that's demonstrated in the tests. Specifically, initializing a service without a Model
and later adding it like app.service('people').Model = db.collection('people')
. If this is a common pattern, there's no way to validate the proper index.
My current plan is to validate that Model
is a Mongo collection in the constructor, and if so run the index check. If not, there's not much we can do. Not as safe as I'd like, but I guess if users are initializing services without a db, then there's not much to be done.
from feathers-mongodb.
It's really just a workaround for the asynchronous initialization of the plugin (which you correctly pointed out we should solve properly). Could we add a verifyIndices
method that can be called manually but also runs in the constructor (if this.Model
is set)?
from feathers-mongodb.
Yeah, that's basically the route I've taken. If Model
exists, then we check it for the proper index. If not, it's up to the user. I'll update the docs to clarify how this works, and that the index is required for the id field to work properly.
from feathers-mongodb.
I just merged #62 which doesn't have the weird workaround for setting the model. Are we still going to add the index check?
from feathers-mongodb.
Related Issues (20)
- RegExp in $in inside query does not get passed to server properly. HOT 2
- An in-range update of @feathersjs/adapter-commons is breaking the build 🚨 HOT 1
- An in-range update of dtslint is breaking the build 🚨 HOT 1
- An in-range update of @types/mongodb is breaking the build 🚨 HOT 3
- Aggregation pipeline for patch HOT 2
- $near query with pagination HOT 1
- Support for bulkWrite HOT 8
- Await setting the model before continuing HOT 3
- $geoNear, $near, and $nearSphere are not allowed in this context
- Regex not working HOT 1
- _objectifyId does not objectify id's nested in query objects
- Multi-tenancy support? HOT 1
- Error when upgrade package mongodb to 4.0.1 HOT 3
- Why this query is not using the index? ( keysExamined: 0 docsExamined: 27417057 ) HOT 3
- Compatibility with mongo driver V4
- ECONNREFUSED when db container is moved/recreated to a new node
- upsert does not create new record HOT 1
- $push not working as expected HOT 1
- Multi create/patch/remove performance HOT 1
- Not working find query with complex query on the _id field (ObjectId conversion) 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 feathers-mongodb.