appy-one / acebase

A fast, low memory, transactional, index & query enabled NoSQL database engine and server for node.js and browser with realtime data change notifications
MIT License
491 stars 27 forks source link

Fix `target` of `mutations` events on wildcard paths #230

Closed appy-one closed 1 year ago

appy-one commented 1 year ago

If mutations or notify_mutations are set on a path containing wildcards (* or named variables), the mutation's target is not being set correctly.

Example:

db.ref('users/*/books').on('mutations', (mutations) => {
  mutations.forEach(snap => {
    const m = snap.val();
    const target = m.target;
    // if mutation is on `users/user1/books/book1/title`, target contains ['ooks', 'book1', 'title']
    // but target should be ['book1', 'title']
  });
});

TODO: snap.ref.path probably contains users/*/books, but should be users/user1/books in above example. Check this, fix it if true.