Yomguithereal / baobab

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

How would I select all sub documents? #442

Closed srossross closed 8 years ago

srossross commented 8 years ago
var tree = new Baobab({
  users: {
    john: {
      firstname: 'John',
      lastname: 'Gold'
    },
    jack: {
      firstname: 'Jack',
      lastname: 'Gold'
    }
  }
});

In this example how would I select all users with the last name "Gold"? eg:

tree.select('users', '*', {lastname: 'Gold'})
Yomguithereal commented 8 years ago

Hello @srossross. Baobab cursors cannot look over multiple nodes in the tree (as opposed to jQuery for instance) for sanity and performance reasons.

What do you need to do here? Retrieve all the users with the last name Gold or do you also need to observe their changes (in that case I can show you how you could solve your issue by using monkeys).

srossross commented 8 years ago

What do you need to do here? Retrieve all the users with the last name Gold

Yes, That was what I was wondering. Thank you for the response.