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

MongoDB Emulation Mode #46

Open
Irrelon opened this issue Jun 12, 2015 · 9 comments
Open

MongoDB Emulation Mode #46

Irrelon opened this issue Jun 12, 2015 · 9 comments

Comments

@Irrelon
Copy link
Owner

Irrelon commented Jun 12, 2015

This is an issue set up to track a new enhancement to make ForerunnerDB optionally behave exactly like MongoDB when doing CRUD calls.

find - Handle dot-notation style query keys.
update - Assume replace instead of update by default.

Implementation is currently suggested to be:

var fdb = new ForerunnerDB();
fdb.mongoEmulation(true);
@YurySolovyov
Copy link

maybe just {enable,disable}MongoEmulation() ?

@Irrelon
Copy link
Owner Author

Irrelon commented Jul 9, 2015

@YuriSolovyov Not sure I follow... could you write the usage in code?

@YurySolovyov
Copy link

@Irrelon I mean instead of

fdb.mongoEmulation(true);

use

fdb.enableMongoEmulation()

or

fdb.disableMongoEmulation()

just to get rid of true/false flag.

@Irrelon
Copy link
Owner Author

Irrelon commented Jul 9, 2015

@YuriSolovyov Ahh I see.

That approach is more terse but increases code size by adding 3 methods to the class instead of 1.

1: fdb.enableMongoEmulation()
2: fdb.disableMongoEmulation()
3: isEnabled = fdb.isMongoEmulationEnabled()

By using a dynamic getter / setter we reduce all these actions down to 1 method call:

1: fdb.mongoEmulation(true)
2: fdb.mongoEmulation(false)
3: isEnabled = fdb.mongoEmulation()

Dynamic getter/setter methods are used throughout ForerunnerDB and are also familiar to those using other libraries like jQuery which make extensive use of them as well.

@YurySolovyov
Copy link

ok, good point.

@Irrelon
Copy link
Owner Author

Irrelon commented Aug 6, 2015

Dev branch now has mongoEmulation() method on fdb, db and collection instances. Find, update and remove all tested and working with dot notation-based queries. Can you guys give it a try and let me know your results?

@kevteljeur
Copy link

I haven't implemented the ForerunnerDB in the project I'm working on (when I got involved in the previous issue thread I was comparing and this issue came up), so I can't check the behaviour to verify for you at this point (we moved on and implemented another library) - my apologies! However, this does make it a contender again once we do, which will be soon enough.

@Irrelon
Copy link
Owner Author

Irrelon commented Aug 6, 2015

Out of interest what library did you go with?

@kevteljeur
Copy link

I used NeDB (this part of the project is Node.js-based) as an in-memory cache. There's still a requirement for a browser storage component, and if we went with NeDB for that then that would still leave a requirement to abstract the browser storage; NeDB seems to be designed more as a fast, file-backed solution, although it will work in the browser too. We're not using LocalForage yet but it does seem to be the way to go, and obviously ForerunnerDB has that covered.

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

3 participants