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

gen.utils.js uses require("mongoose") instead of the mongoose from Fawn.init #46

Closed
jake-billings opened this issue Jan 25, 2018 · 3 comments

Comments

@jake-billings
Copy link
Contributor

I'm not super familiar with the structure of this repository. I'll create a pull request if I find some free time and you guys agree with me.

I've had a lot of trouble getting Fawn to work because in some places it uses the statement "require("mongoose")"

By default, npm does not install the same version of mongoose as Fawn. As a result, an additional copy of mongoose is cloned into node_modules/fawn/node_modules/mongoose.

When fawn calls "require("mongoose")" node loads this separate instance of mongoose. As a result, none of the mongoose models I have defined are registered. This results in errors when I try to run transactions.

My current workaround is to manually check the version of mongoose Fawn uses (4.11.3) and lock my project to the same one. This is not ideal for my dev environment, but it does work.

I believe that using the copy of mongoose from Fawn.init throughout the entirety of Fawn would fix this issue.

gen.utils.js is the source of the error I encountered, and the file uses require() to load mongoose. I haven't checked if require() is used to load mongoose anywhere else.

@e-oj
Copy link
Owner

e-oj commented Jan 25, 2018

Oh yeah. I added getCollection (the only function in the file which needs the user's version of mongoose) to gen.utils on the last release and forgot to change the mongoose source. Good catch. Feel free to open a PR

jake-billings added a commit to jake-billings/Fawn that referenced this issue Jan 25, 2018
…goose from Fawn.init; move all functions that depend on mongoose from gen utils to db utils; update all references accordingly
@jake-billings
Copy link
Contributor Author

jake-billings commented Jan 25, 2018 via email

@e-oj
Copy link
Owner

e-oj commented Jan 25, 2018

Open the pr on dev and I'll merge it. Solid work 👌

e-oj added a commit that referenced this issue Jan 25, 2018
Fix #46: gen.utils.js uses require("mongoose") instead of the mongoos…
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants