Comments (4)
@roger-kaybus k will look into it. I remember thinking at one point that the interface seemed redundant, but there was a reason I made the decision and I think it has to do with the way mongoose works. I'll look into it and let you know.
from mongoose-fixture.
Reviewed some of the code fairly quickly. I think my intention was as follows.
A little background on Mongoosejs, by default it will take whatever 'ModelKey' you pass into Mongoose.model('ModelKey', Schema)
and if you do not specify a collection name in the schema.options.collection it will attempt to generate one for you. For instance if you did Mongoose.model('Kitten', Schema)
it would create a collection in mongodb called kittens
.
There are problems with Mongoosejs auto-generating collection names, specifically I had an instance of the model 'Facility' which was generating facilitys
which is inaccurate I wanted facilities
so in my schema I set the collection option to facilities. The problem then when I ran mongoose-fixture with just a collection
key of 'facilities' the Mongoose.model(...)
method was incapable of finding the correct model/collection mapping. Even though the delete would work since the collection name did map correctly.
So... with that said I reviewed my project that has multiple mis-matching itemName / collection names and they work fine... I think your problem might be in setting two different values you need to map your fixture.collection to the custom collection name you define on your scheme
module.exports = function(mongoose){
var facilitySchema = mongoose.Schema({
internalName:{type:String},
name:{type:String},
},
// extra options, this overrides the default collection name
// that would be set by model as facilitys
{
collection:'facilities'
}
);
return facilitySchema;
};
Let me know if this solves your problem. Maybe I'll see what my options are for warning a client that by mis-matching itemName and Collection requires the collection
to be defined on the scheme. Pretty sure I can bubble the message up.
from mongoose-fixture.
@roger-kaybus when you get a chance let me know the status and if you're all set please close the issue.
from mongoose-fixture.
its working for me fine right now. I'll close this.
from mongoose-fixture.
Related Issues (20)
- Cluster support for mongodb HOT 20
- Improve CLI HOT 1
- Review the current interface for fixture loading within an app
- Auto generate data-fixtures using the defined mongo-database
- Improve CLI interface or Mongoose-Config to support node-conf for DEV, QA, PROD mongo connections
- Versioning for Mongoose Schemas
- Error for duplicate models from config
- Zealous Exception handling during (reset || remove)
- Update Data Fixtures
- Fixture Helper Service
- Unable to create fixture-listings with model dependencies not in loading scope
- How to add a data fixture for GridFS? HOT 4
- Difference in schema between mongoose and mongoose fixture HOT 2
- MissingSchemaError: Schema hasn't been registered for model "Product". HOT 7
- TypeError: Cannot call method 'create' of undefined
- Getting 'Arguments to path.resolve must be strings' for every command HOT 5
- Add an example that uses mongodb references HOT 16
- Improve comment added to generated fixture file / boilerplate HOT 2
- Implment simpler interface for collections and references HOT 7
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 mongoose-fixture.