e-oj / Fawn

Transactions for MongoDB (See the README)
https://www.npmjs.com/package/fawn
MIT License
486 stars 54 forks source link

save() converts Int64 value to String #45

Closed jeronimo13 closed 6 years ago

jeronimo13 commented 6 years ago

Let's say I have a piece of code that saves the question and updates user property:

 task
                .save("questions", q)
                .update("users", {id: user.id}, {$addToSet: {'system.askedQuestionsArray': q.id}})
                .run()
                .then(resolve(q));

But, when I looked at Mongo I looked at 'createdAt' property in Question entity, it has String value instead of Int64

For example, this code(obviously not a transaction) saves Question entity and 'createdAt' property is Int64

 q.save()
.then(User.findOneAndUpdate({id: user.id}, {$addToSet: {'system.askedQuestionsArray': q.id}}))
                .then(resolve(q))

Additional info:

Schema:

let questionSchema = ActiveRecord.schema({
   ...
    createdAt: {type: ActiveRecord.types.Long, default: moment.utc().valueOf()},
});

Dependecies: "mongoose": "4.13.8", "mongoose-long": "^0.1.1", "fawn": "^2.1.0"

Please, help!

e-oj commented 6 years ago

upgrade your fawn version to 2.1.1. See if that helps

jeronimo13 commented 6 years ago

@e-oj worked like a charm! Marvelous!