-
Notifications
You must be signed in to change notification settings - Fork 54
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
Not rolling back #74
Comments
there are 3 queries that needs to be run...1st saving reply in Reply collection..2nd updating comment collection with newReply's id...3rd save new Notification in Notification collection i have intentionally made mistake while saving 3rd query so that error should occur... |
I've not been able to reproduce this error. The following script rolls back the changes as expected: let mongoose = require("mongoose");
let Fawn = require("./lib/fawn");
mongoose.connect("mongodb://127.0.0.1:27017/testDB");
Fawn.init(mongoose);
let task = Fawn.Task();
let Reply = mongoose.model("replies", new mongoose.Schema({
text: {type: String, required: true},
list: {type: [String], required: true}
}));
task = task.save(Reply, {text: "I replied!", list: ["some val"]})
.save(Reply, {text: "I replied again!", list: ["Another One!"]})
.update(Reply, {_id: {$ojFuture: "0._id"}}, {$push: {list: 3}})
.save(Reply({
tex: "bad reply",
list: ["good list"]
}));
(async () => {
try{
await task.run({useMongoose: true});
}
catch(err){
console.log(err);
}
try{
let replies = await Reply.find();
console.log("replies: ", replies);
}
catch(err){
console.log(err);
}
})(); Let me know if I'm missing something. |
This is the output I got btw: { ValidationError: replies validation failed: text: Path `text` is required.
at ValidationError.inspect (/Users/emmanuelolaojo/Desktop/Fawn/node_modules/mongoose/lib/error/validation.js:57:23)
at ValidationError.deprecated (internal/util.js:70:15)
at formatValue (util.js:467:31)
at inspect (util.js:328:10)
at Object.formatWithOptions (util.js:182:12)
at Console.(anonymous function) (console.js:188:15)
at Console.log (console.js:199:31)
at /Users/emmanuelolaojo/Desktop/Fawn/test.js:31:13
errors:
{ text:
{ ValidatorError: Path `text` is required.
at new ValidatorError (/Users/emmanuelolaojo/Desktop/Fawn/node_modules/mongoose/lib/error/validator.js:25:11)
at validate (/Users/emmanuelolaojo/Desktop/Fawn/node_modules/mongoose/lib/schematype.js:758:13)
at /Users/emmanuelolaojo/Desktop/Fawn/node_modules/mongoose/lib/schematype.js:805:11
at Array.forEach (<anonymous>)
at SchemaString.SchemaType.doValidate (/Users/emmanuelolaojo/Desktop/Fawn/node_modules/mongoose/lib/schematype.js:765:19)
at /Users/emmanuelolaojo/Desktop/Fawn/node_modules/mongoose/lib/document.js:1506:9
at process._tickCallback (internal/process/next_tick.js:61:11)
message: 'Path `text` is required.',
name: 'ValidatorError',
properties: [Object],
kind: 'required',
path: 'text',
value: undefined,
reason: undefined,
'$isValidatorError': true } },
_message: 'replies validation failed',
name: 'ValidationError' }
|
i got this Error : |
And First 2 replies saved in database |
What's Your version of mongoose and fawn? |
Mongoose : 5.4.9 btw i got same Error as u got. i.e Validation Error when i used let Fawn = require("./lib/fawn"); |
It's tied to the mongoose version. Fawn uses v4.12.3 and I was able to reproduce the error by upgrading to 5.4.9. This issue will be addressed in the next update. I'll look for other upgrade related bugs as well. Thanks for pointing this out. |
Yeah i also got this just now...working perfectly with mongoose@4.13.18..but not with latest version of mongoose i.e mongoose@5.4.9 |
Thanks for ur time..waiting for next update |
Comment.findOne({ _id: req.params.commentID }, (err, doc) => {
if (err) {
res.json({ success: false, message: 'Reply not Saved...Something went Wrong.' })
} else if (!doc) {
res.json({ success: false, message: 'Reply not Saved...Something went Wrong.' })
} else {
User.findOne({ username: doc.createdBy }, { notificationList: 1 }, (err, user) => {
if (err) {
res.json({ success: false, message: err });
} else if (!user) {
res.json({ success: false, message: "Reply not Saved...Something went Wrong." });
} else {
var newReply = new Reply({
repliedBy: req.body.username,
body: req.body.replyBody,
createdAt: Date.now()
})
The text was updated successfully, but these errors were encountered: