Giter Club home page Giter Club logo

locallydb's People

Contributors

btwael avatar hugohil avatar krazyjakee avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

locallydb's Issues

TypeError : 'cid' of undefined

Dear Wael Boutglay,

I've been evaluated your library and found an issue after remove() operation. Running 0.0.3 version.

// Insert/add/push a list of elements
collection.insert([
{name: "sphinx", mythology: "greek", eyes: 2, sex: "f", hobbies: ["riddles","sitting","being a wonder"]},
{name: "hydra", mythology: "greek", eyes: 18, sex: "m", hobbies: ["coiling","terrorizing","growing"]},
{name: "huldra", mythology: "norse", eyes: 2, sex: "f", hobbies: ["luring","terrorizing"]},
{name: "cyclops", mythology: "greek", eyes: 1, sex: "m", hobbies: ["staring","terrorizing"]},
{name: "fenrir", mythology: "norse", eyes: 2, sex: "m", hobbies: ["growing","god-killing"]},
{name: "medusa", mythology: "greek", eyes: 2, sex: "f", hobbies: ["coiling","staring"]}
]);

var entry = collection.where({ name : 'fenrir' })
console.log(entry[0].cid); // => Display 4
collection.update( entry[0].cid, { eyes : 7 } );
console.log( entry[0].cid);
// => { name: 'fenrir', mythology: 'norse', eyes: 7, sex: 'm', hobbies: [ 'growing', 'god-killing' ], cid: 4, '$created': '2014-09-15T19:50:22.090Z', '$updated': '2014-09-15T19:50:22.091Z' },

var one = collection.get(2);
console.log(one); // => {name: "huldra", mythology: "norse", eyes: 2, sex: "f", hobbies: ["luring","terrorizing"]}
collection.remove(2);
collection.save();

var list = collection.items;
console.log(list); // => The whole list [ ...{ hydra ...} , , { cyclops ... }, ...}] but there is a null element between hydra and cyclops

var entry = collection.where({ name : 'fenrir' })
console.log(entry[0].cid); // => Display 4
collection.update( entry[0].cid, { eyes : 7 } ); //or collection.update( 4, { eyes : 7 } );
// => .../node_modules/locallydb/lib/collection.js:107
// if (element.cid === cid) {
// ^
// TypeError: Cannot read property 'cid' of undefined
// at Collection.update (/home/sjphyun/Angular/gardplc/node_modules/locallydb/lib/collection.js:107:20)
// ...

Best regards,

where returns different data structure

Dear Wael Boutglay,

I encountered the following problem. where() returns { items : [A,B,C,D]} on Linux However, I see the different result from windows/Mac platforms. It returns a list instead. [A,B,C,D].

Thanks.

removeCollection fails

There's a little bug that makes removeCollection method fail:

removeCollection: (name) ->
  collecton = @collection(name)
  fs.unlinkSync(collection._cpath)

should just be

removeCollection: (name) ->
  collection = @collection(name)
  fs.unlinkSync(collection._cpath)

where format for "exists in nested array"

Is there a way to use the .where where one can find all items with an array having a specific value?

lets say for

collection.insert([
  {name: "sphinx", mythology: "greek", eyes: 2, sex: "f", hobbies: ["riddles","sitting","being a wonder"]},
  {name: "hydra", mythology: "greek", eyes: 18, sex: "m", hobbies: ["coiling","terrorizing","growing"]},
  {name: "huldra", mythology: "norse", eyes: 2, sex: "f", hobbies: ["luring","terrorizing"]},
  {name: "cyclops", mythology: "greek", eyes: 1, sex: "m", hobbies: ["staring","terrorizing"]},
  {name: "fenrir", mythology: "norse", eyes: 2, sex: "m", hobbies: ["growing","god-killing"]},
  {name: "medusa",  mythology: "greek", eyes: 2, sex: "f", hobbies: ["coiling","staring"]}
]);

I am looking for all monsters with terrorizing as a hobbie

One could

var a = [];
collection.items.map(function(val){
    if(val.hobbies && val.hobbies.indexOf("terrorizing")>-1){
        a.push(val);
    }   
})

them, but wondering if there is a .where syntax for it.

`Collection.remove` does not save to disk after remove but in loop before remove

Going through the source Code of collection.coffee, I noticed something odd in the remove method when autosave = true. Since I don't know CS, I checked the compiled source and confirmed my suspicion:

  1. save is called in every loop iteration
  2. … until the element to be removed is found, which is then deleted but the changes are not written to disk.

So this should probably read like:

remove: (cid) ->
    for element, i in @items
        if element.cid is cid
            @items.remove i
            @save() if @autosave
            return true
    return false

Site is expired

Is there a backup somewhere for the site data? I want to see the docs.

upsert isn't work correctly

Current upsert method contains the following code:

if (check.length > 0) {
.. do update...
}
else {
.. do insert...
}

But 'check' variable is an object, not an array, contained 'items' property within self with length property.
May be there are cases when that statement isn't true, but currently 'upsert' is broken.

Sync or async?

Stupid question, but … Are the operations/methods sync or async?

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.