Giter Club home page Giter Club logo

Comments (9)

techfort avatar techfort commented on June 16, 2024

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.

goatslacker avatar goatslacker commented on June 16, 2024

Awesome, I've been playing around with this and it's pretty cool thus far. There are only two things I'm wishing for:

  1. 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.

  1. 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 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.

from lokijs.

LivesleyWA avatar LivesleyWA commented on June 16, 2024

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.

techfort avatar techfort commented on June 16, 2024

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.

LivesleyWA avatar LivesleyWA commented on June 16, 2024

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.

techfort avatar techfort commented on June 16, 2024

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 | 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]:[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.

LivesleyWA avatar LivesleyWA commented on June 16, 2024

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 | USA

On 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.

techfort avatar techfort commented on June 16, 2024

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:

  1. 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.

  1. 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.

goatslacker avatar goatslacker commented on June 16, 2024

👍

from lokijs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.