Open tobiasoberrauch opened 10 years ago
@tobiasoberrauch sorry I missed this originally, are you still having issues and need help?
There is no prescribed way to register your schemas, it depends on your application/usage pattern. In order to have reusable schemas I recommend this method which plays nicely with mongoose-fixture and still allows for shared schemas for express-apps or other services.
//user.js
module.exports = function(mongoose, conn) {
var Schema = mongoose.Schema;
var UserSchema = new mongoose.Schema({
name: {type: String, required: true}
});
// register model here, though I'd recommend against it see
// https://github.com/mgan59/mongoose-fixture/issues/25
mongoose.model('User', UserSchema);
return {
name: 'User',
schema: UserSchema
};
};
Let me know if this doesn't work and feel free to post more code if you need help.
Hi,
during develop my project I regnocnized a difference between the expected schemas for mongoose [1] and mongoose fixture [2]:
[1]
[2]
My problem is that I can't find a schema that fits for both. What did I wrong?
Thanks for helping me :)
Cheers Tobias