e-oj / Fawn

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

Always cast _id to ObjectID #32

Closed maxsh8x closed 6 years ago

maxsh8x commented 7 years ago

I have _id as number. Can i disable this behavior?

e-oj commented 7 years ago

Right now, no, you can't disable that behavior. But I see what you mean; an option like that would be useful. This could be added to the next release.

e-oj commented 7 years ago

The workaround would be to store your integer _id in a different field ("id" maybe?)

laosb commented 6 years ago

Hello, I'm trying to use this package with Meteor - which uses String for _ids. I wonder how hard will be to implement this change?

e-oj commented 6 years ago

This has been fixed. Upgrade your Fawn version and it should be fine. Feel free to reopen this issue if it persists

laosb commented 6 years ago

if i try update with _id field it still emits an error; anyway i dont use _id for now, so everything works now. i will let you know if i could still see this problem later. thanks!

e-oj commented 6 years ago

You're getting update errors with _id? That shouldn't be happening. What's the error? also, can you share the code? @laosb

laosb commented 6 years ago

it emits an hard-to-understand max call stack size exceeded. it could be fawn's fault but also can be mine. further investigation is on its way but i would just take one day off on this new year's day - happy new year from china!

e-oj commented 6 years ago

Happy new year to you too 🎉

laosb commented 6 years ago

@e-oj Figured out. I tried to return the result of task.run(), which includes cyclic ref. Meteor tried to stringify it before sending to client, and that caused a maximum call stack size exceed. My fault! Safe to close now. Thank you for your patience!

e-oj commented 6 years ago

No problem 👍