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

Use joliCreator function to allow multiple db instances; Add to exports var instead of replacing it. #20

Closed
wants to merge 1 commit into from

Conversation

nicjansma
Copy link
Contributor

This looks like a big change via the diff, but there's no change between from the previous var joli = { ... }, it's just wrapped in a new joliCreator() function now. There's a second small change at the end to make CommonJS work -- instead of replacing the exports object, we need to add properties to it. I don't know if replacing exports worked in 1.7.x, but it doesn't work in 1.8.x.

The two changes are:

  1. For CommonJS usage, a single var joli in the module doesn't work if you want multiple db instances. Subsequent require('joli').connect()s will overwrite previous connection since they're using the same joli var in the module. Instead, a new joliCreator() function is used that will return a new joli object on each call. For parity with Ti.include(), create a module joli var with this function right away. This allows us to have multiple joli connections with CommonJS usage.

  2. CommonJS usage shouldn't replace the entire exports object, it should add to the object as needed. (https://jira.appcelerator.org/browse/TIMOB-5406)

…ts var instead of replacing it.

* For CommonJS usage, a single joli var doesn't work if you want multiple db instances. Subsequent require('joli').connect()s will overwrite previous connection since they're using the same joli var in the module.  Instead, a new joliCreator() function is used that will return a new joli object on each call.  For parity with Ti.include(), create a module joli var with this function right away.  This allows us to have multiple joli connections with CommonJS usage.
* CommonJS usage shouldn't replace the entire exports object, it should add to the object as needed. (https://jira.appcelerator.org/browse/TIMOB-5406)
@xavierlacot
Copy link
Owner

Hi Nic,

I just pushed the changes that you proposed, along with other modifications. See dc0c3a0

Thanks a lot,

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

Successfully merging this pull request may close these issues.

None yet

2 participants