Comments (9)
I like this idea a lot, in some ways Collection
is really the central class to Loki rather than the db class itself. I exposed Collection through Loki.prototype.Collection = Collection
and created a test which you can see here. I also included and example subclass. Unfortunately it's a bit clumsy because of the need of having to run the Collection constructor for it work correctly but you get the gist.
from lokijs.
Awesome, I've been playing around with this and it's pretty cool thus far. There are only two things I'm wishing for:
- The Collection should be in a separate file.
The reason for this is so all the other code doesn't get included in the bundle. It shouldn't be difficult to separate this out, in fact I'm willing to PR it. Ideally the syntax for including this would be:
var Collection = require('lokijs/Collection')
Some things will need to change in order for this to happen, most likely you'll have to introduce some build/bundle step to wrap collection back into a single file for browser use. This can all be done with browserify, webpack, or any other bundler.
- There should be a way to
serialize
/load
a collection. Serialize is pretty trivial in itself, loading is the logic that would be very useful. Currently this is all tucked away on theLoki.prototype
found here it would be cool to have aCollection.prototype.loadJSON
method as well that does all this logic (copy over the data, reinit the listeners, etc) Let me know if you want a PR for this one too.
from lokijs.
Slightly orthogonal to this but in the same field.
As far as I am aware, and I may have missed it, there is no way to access a collection other than through the original object returned when the collection is created.
It would be nice to be able to enumerate collections in the database and get a reference to a given collection object. In my case, I am using LokiJS for unit tests and would like to get access to the underlying data without going through my intermediate code (i.e. to test that if object x has been inserted). I would add this to your suggestions with respect to collection.
I like the idea of a collection sub-class but I need to think about whether this would meet my requirements.
from lokijs.
Hey William,
don't know if you're working off v1.0 on npm or off the source but there
should be a getCollection(collName) method, and in v1.1 there's definitely
a listCollections method.
Would that do the job for you?
v1.1 is officially getting released tomorrow, there will be a method "anonym" which will let create a collection on the fly with chainable capabilities for quick tests.
On Sat, Dec 20, 2014 at 8:24 PM, William Livesley [email protected]
wrote:
Slightly orthogonal to this but in the same field.
As far as I am aware, and I may have missed it, there is no way to access
a collection other than through the original object returned when the
collection is created.
It would be nice to be able to enumerate collections in the database and
get a reference to a given collection object. In my case, I am using LokiJS
for unit tests and would like to get access to the underlying data without
going through my intermediate code (i.e. to test that if object x has been
inserted). I would add this to your suggestions with respect to collection.
I like the idea of a collection sub-class but I need to think about
whether this would meet my requirements.—
Reply to this email directly or view it on GitHub
#49 (comment).
from lokijs.
Ah - missed it - should have looked at the code not just the documentation! I suppose we should add rtfc to rtfm for developing projects :-).
That will do it - many thanks for the prompt response.
Alex Livesley
W. Alex Livesley
President and CEO | Ilexium Incorporated
www.ilexium.comhttp://www.ilexium.com | [email protected]:[email protected]
465 Bellevue Avenue #35 | Oakland | CA 94610 | USA
On Dec 20, 2014, at 12:35 PM, Techfort <[email protected]mailto:[email protected]> wrote:
Hey William,
don't know if you're working off v1.0 on npm or off the source but there
should be a getCollection(collName) method, and in v1.1 there's definitely
a listCollections method.
Would that do the job for you?
On Sat, Dec 20, 2014 at 8:24 PM, William Livesley <[email protected]mailto:[email protected]>
wrote:
Slightly orthogonal to this but in the same field.
As far as I am aware, and I may have missed it, there is no way to access
a collection other than through the original object returned when the
collection is created.
It would be nice to be able to enumerate collections in the database and
get a reference to a given collection object. In my case, I am using LokiJS
for unit tests and would like to get access to the underlying data without
going through my intermediate code (i.e. to test that if object x has been
inserted). I would add this to your suggestions with respect to collection.
I like the idea of a collection sub-class but I need to think about
whether this would meet my requirements.—
Reply to this email directly or view it on GitHub
#49 (comment).
—
Reply to this email directly or view it on GitHubhttps://github.com//issues/49#issuecomment-67748673.
from lokijs.
Thank you for pointing out that the docs are missing that particular bit.
Finalizing docs right now for the release so that was perfect timing.
On Sat, Dec 20, 2014 at 8:58 PM, William Livesley [email protected]
wrote:
Ah - missed it - should have looked at the code not just the
documentation! I suppose we should add rtfc to rtfm for developing projects
:-).That will do it - many thanks for the prompt response.
Alex Livesley
W. Alex Livesley
President and CEO | Ilexium Incorporated
www.ilexium.comhttp://www.ilexium.com | [email protected]
mailto:[email protected]
465 Bellevue Avenue #35 | Oakland | CA 94610 | USAOn Dec 20, 2014, at 12:35 PM, Techfort <[email protected]<mailto:
[email protected]>> wrote:Hey William,
don't know if you're working off v1.0 on npm or off the source but there
should be a getCollection(collName) method, and in v1.1 there's definitely
a listCollections method.
Would that do the job for you?On Sat, Dec 20, 2014 at 8:24 PM, William Livesley <
[email protected]:[email protected]>
wrote:Slightly orthogonal to this but in the same field.
As far as I am aware, and I may have missed it, there is no way to
access
a collection other than through the original object returned when the
collection is created.
It would be nice to be able to enumerate collections in the database and
get a reference to a given collection object. In my case, I am using
LokiJS
for unit tests and would like to get access to the underlying data
without
going through my intermediate code (i.e. to test that if object x has
been
inserted). I would add this to your suggestions with respect to
collection.
I like the idea of a collection sub-class but I need to think about
whether this would meet my requirements.—
Reply to this email directly or view it on GitHub
#49 (comment).—
Reply to this email directly or view it on GitHub<
https://github.com/techfort/LokiJS/issues/49#issuecomment-67748673>.—
Reply to this email directly or view it on GitHub
#49 (comment).
from lokijs.
Wasn’t a criticism btw, you guys are clearly busy. Your documentation has been excellent which is why I hadn’t looked to the code.
What I see so far is great. I have considerable experience using both CouchDB and MongoDb. I am no fan of CouchDB and I see this as a good candidate for a mobile supplement to MongoDB.
Alex
W. Alex Livesley
President and CEO | Ilexium Incorporated
www.ilexium.comhttp://www.ilexium.com | [email protected]:[email protected]
465 Bellevue Avenue #35 | Oakland | CA 94610 | USA
On Dec 20, 2014, at 1:00 PM, Techfort <[email protected]mailto:[email protected]> wrote:
Thank you for pointing out that the docs are missing that particular bit.
Finalizing docs right now for the release so that was perfect timing.
On Sat, Dec 20, 2014 at 8:58 PM, William Livesley <[email protected]mailto:[email protected]>
wrote:
Ah - missed it - should have looked at the code not just the
documentation! I suppose we should add rtfc to rtfm for developing projects
:-).That will do it - many thanks for the prompt response.
Alex Livesley
W. Alex Livesley
President and CEO | Ilexium Incorporated
www.ilexium.comhttp://www.ilexium.comhttp://www.ilexium.com | [email protected]:[email protected]
mailto:[email protected]
465 Bellevue Avenue #35 | Oakland | CA 94610 | USAOn Dec 20, 2014, at 12:35 PM, Techfort <[email protected]mailto:[email protected]<mailto:
[email protected]mailto:[email protected]>> wrote:Hey William,
don't know if you're working off v1.0 on npm or off the source but there
should be a getCollection(collName) method, and in v1.1 there's definitely
a listCollections method.
Would that do the job for you?On Sat, Dec 20, 2014 at 8:24 PM, William Livesley <
[email protected]:[email protected]:[email protected]>
wrote:Slightly orthogonal to this but in the same field.
As far as I am aware, and I may have missed it, there is no way to
access
a collection other than through the original object returned when the
collection is created.
It would be nice to be able to enumerate collections in the database and
get a reference to a given collection object. In my case, I am using
LokiJS
for unit tests and would like to get access to the underlying data
without
going through my intermediate code (i.e. to test that if object x has
been
inserted). I would add this to your suggestions with respect to
collection.
I like the idea of a collection sub-class but I need to think about
whether this would meet my requirements.—
Reply to this email directly or view it on GitHub
#49 (comment).—
Reply to this email directly or view it on GitHub<
https://github.com/techfort/LokiJS/issues/49#issuecomment-67748673>.—
Reply to this email directly or view it on GitHub
#49 (comment).
—
Reply to this email directly or view it on GitHubhttps://github.com//issues/49#issuecomment-67749517.
from lokijs.
Hey Josh,
I'm going to open two new issues and close this one to avoid scope creep on
the issue itself. Thanks for the great ideas.
On Sat, Dec 20, 2014 at 12:00 AM, Josh Perez [email protected]
wrote:
Awesome, I've been playing around with this and it's pretty cool thus far.
There are only two things I'm wishing for:
- The Collection should be in a separate file.
The reason for this is so all the other code doesn't get included in the
bundle. It shouldn't be difficult to separate this out, in fact I'm willing
to PR it. Ideally the syntax for including this would be:var Collection = require('lokijs/Collection')
Some things will need to change in order for this to happen, most likely
you'll have to introduce some build/bundle step to wrap collection back
into a single file for browser use. This can all be done with browserify,
webpack, or any other bundler.
- There should be a way to serialize/load a collection. Serialize is
pretty trivial in itself, loading is the logic that would be very useful.
Currently this is all tucked away on the Loki.prototype found here
https://github.com/techfort/LokiJS/blob/master/src/lokijs.js#L468 it
would be cool to have a Collection.prototype.loadJSON method as well that
does all this logic (copy over the data, reinit the listeners, etc) Let me
know if you want a PR for this one too.—
Reply to this email directly or view it on GitHub
#49 (comment).
from lokijs.
from lokijs.
Related Issues (20)
- Wrong result while quering by $in with an index on a large numeric string property HOT 1
- Wrong result while quering by $lt/lte/gte with a large numeric string property HOT 1
- $lokijs is not received with findOne query
- Corrupted idIndex and $loki value HOT 1
- [Question] Subscribe: performance and efficiency HOT 3
- Incorrect implementation of `getObjectDelta`
- Incorrect implementation of `ResultSet.update`
- TTL options of Collections do not persist (re-open #626)
- Is this project dead? HOT 14
- Incorrect implementation of unit test of `immutable`
- Incorrect implementation of `inflate`
- `simpleSort` with `useJavascriptSorting` don't support `dotNotation`
- Unit test of `persistence` is not correctly implemented
- `compoundEval` is not correctly implemented
- The unit test of `sotringIndexing` is not correctly implemented
- The unit test of `test` is not correctly implemented
- Error: this collection cannot be loaded lazily HOT 2
- Use https in description
- [Question] Reload database / cancel changes HOT 2
- Feature Request: IPFS Adapter HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lokijs.