Meteor-Community-Packages / ground-db

GroundDB is a thin layer providing Meteor offline database and methods
https://atmospherejs.com/ground/db
MIT License
569 stars 76 forks source link

Meteor does not currently support objects other than ObjectID as ids #177

Closed Mattze96 closed 8 years ago

Mattze96 commented 8 years ago

Hello,

i'm using ground:db from the grounddb-caching-2016 branch.

When accessing external database i get the following error in offline-mode:

Meteor does not currently support objects other than ObjectID as ids

Is there any fix or wrapper available? The point is, that i'm not able to write into the external collection

raix commented 8 years ago

Mongo.Collection has a property called idGeneration='STRING'

Mattze96 commented 8 years ago

no, not working with that.

KeyValueStore = new Mongo.Collection('keyvaluestore'); 
Test = new Mongo.Collection('test', {idGeneration: 'STRING'});

Example documents:

KeyValueStore

{ "_id" : "hits", "val" : 388974 }

Test

 { "_id" : ObjectId("55b5f86f7b2179e52b21300c"), "val" : "foobar"}

KeyValueStore is not causing any errors, but Test does. I think it has to do something with ObjectId().

raix commented 8 years ago

Yes - I don't think objectId is supported on the client by Meteor.Collection https://github.com/meteor/meteor/issues/4193

raix commented 8 years ago

https://github.com/meteor/meteor/issues/6219

A possible explanation in: https://github.com/GroundMeteor/db/issues/99#issuecomment-189903236

Mattze96 commented 8 years ago

thanks, so it is no bug in ground:db.

I came up with a really dirty fix. I think it isn't even efficient...

  Meteor.publish('test', function(argument){
    var self = this;
    Test.find().forEach(function(doc) {
      self.added('test', doc._id._str, doc);
    });
    self.ready();
  });
raix commented 8 years ago

It autoclosed... Let me know if this is still an issue in 2.0.0-rc.5 :)