Yomguithereal / baobab

JavaScript & TypeScript persistent and optionally immutable data tree with cursors.
MIT License
3.15k stars 116 forks source link

Hot to find the data from collection? #456

Closed janryWang closed 8 years ago

janryWang commented 8 years ago

like this


const tree = new Baobab({collection : [{id:1223},{id:455}] })

tree.select('collection').select(
     Baobab.query(
       {
          id:{$gt:1000}
       }
     )
)
Yomguithereal commented 8 years ago

Hello @janryWang. What do you need to achieve in the end. Get the desired data, or select it to listen to its updates?

janryWang commented 8 years ago

I just want search dataļ¼Œand I need a powerful search feature like mongo query languagešŸ˜„

Yomguithereal commented 8 years ago

I you just want to search data, you can just use JavaScript builtin filter method like this:

const collection = tree.get('collection');

const foundItems = collection.filter(function(item) {
  return item.id > 1000;
});

I what you need is a configuration model supplied as data like in Mongo, then Baobab won't help you but you could use its data along with different library doing just this kind of work.

Yomguithereal commented 8 years ago

Something like Sift for instance.

janryWang commented 8 years ago

Perfect ! Thank you very much! I like it !