Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't working with Mongoose version upper than 4.7.9 #18

Closed
sergey-zero opened this issue Apr 28, 2017 · 5 comments
Closed

Don't working with Mongoose version upper than 4.7.9 #18

sergey-zero opened this issue Apr 28, 2017 · 5 comments

Comments

@sergey-zero
Copy link

Don't working with Mongoose version upper than 4.7.9
Nodejs v7.7.3

@ramiel
Copy link
Owner

ramiel commented Apr 28, 2017

I have tests passing with version 4.9.6
Please, can you provide some more information? What the error is exactly? How can I reproduce it?

@sergey-zero
Copy link
Author

https://github.com/sergey-zero/example
objects don't have order_id field with 4.9.7 version of mongoose, but working fine on 4.7.9
maby i'm do something wrong
[ { _id: 5909717b8f1fde1b4f25e563, test: 'first', __v: 0 }, { _id: 590971f2f68e0e1bd036f5ce, test: '1aa55', __v: 0 }, { _id: 590971f7855a5a1bde32d665, test: '13352', __v: 0 }, { _id: 590973225934721d6f69125a, test: '111ce', __v: 0 } ]

@ramiel
Copy link
Owner

ramiel commented May 3, 2017

I'll have a look soon.

@ramiel
Copy link
Owner

ramiel commented May 3, 2017

Starting from mongoose>4.7.9 looks like it's not possible anymore to change the schema after the model definition (see Automattic/mongoose#5203). This is true for plugins too, so if in your code you define the plugin before the model

const testSchema = new mongoose.Schema({
    test: String,
    order_id: Number
});
// The plugin
testSchema.plugin(sequence, {inc_field: 'order_id'});
// And then the model
const Test = mongoose.model('Test',testSchema);

it should work. Let me know

@sergey-zero
Copy link
Author

Wow, you are GOD, it's really works. Thank you so much!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants