derbyjs / racer

Realtime model synchronization engine for Node.js
1.19k stars 118 forks source link

queries (using derby) doesn't follow established naming convention of ids #20

Closed cjblomqvist closed 11 years ago

cjblomqvist commented 12 years ago

Using paths, one can do:

model.subscribe( 'document.*', function( err, scoped_model ) {

    assert( 
          model.get( 'document.' + <id#1> )
        ===
          {
            _id: 'test',
            other_field: 'test'
          }
      ); // TRUE

  });

But using queries, this is the current behavior:

model.subscribe( model.query('document').where('_id').within( [ <id#1>, <id#2>, ... <all ids> ] ), function( err, scoped_model ) {

    assert( 
          model.get( 'document.' + <id#1> )
        ===
          {
            _id: 'test',
            other_field: 'test'
          }
      ); // FALSE

      // But
      assert( 
          model.get( 'document.' + <id#1> )
        ===
          {
            id: 'test',
            other_field: 'test'
          }
      ); // TRUE

  });

Notice the difference of the name of the id field. Also worth noticing is that it's still (only) possible to query on the _id field.

(PS. I'm using the racer-mongo adapter and a MongoDB in the backend - dunno if that info helps though)

nateps commented 11 years ago

No longer relevant in 0.5