meteor-file-collection
meteor-file-collection copied to clipboard
grounddb error using file-collection collections
I'm trying to use GroundDB to sync file-collection metadata on the client.
Using the collection directly throws: " Uncaught Error: Meteor does not currently support objects other than ObjectID as ids."
I guess this would require file-collection use ids differently, which would be a major refactor.
Is there any workaround for this?
The grounddb code is not complex, see sample below.
Meteor.subscribe('myData');
// check if the grounddb resources exist.
if( !Ground.lookup('myFiles.files') ){
//ground myData from file-collection
Ground.Collection(myData);
myData.on('loaded', function(evt){
console.log('ground db loaded')
/* Do Something */
});
}
file-collection can _only_ use ObjectID
s for _id
values, because the gridFS spec requires it. A file-collection would no longer be a conformant gridFS .files
collection if the _id
value is anything other than an ObjectID
.
So I'm not sure where that error is coming from. I haven't used GroundDB for any purpose, let alone with file-collection, but there's no inherent reason I can think of why it shouldn't work.
In developer mode, if you open the mongo console, you should easily be able to see the type of the _id
fields:
% meteor mongo
# MongoDB shell version: 2.6.7
# connecting to: 127.0.0.1:3001/meteor
meteor:PRIMARY> show collections
# myFiles.chunks
# myFiles.files
# myFiles.locks
# meteor_accounts_loginServiceConfiguration
# system.indexes
# users
meteor:PRIMARY> db.fs.files.findOne()
# {
# "_id" : ObjectId("127b185189fb333d394ef97c"),
# "length" : 85983232,
# "md5" : "2bf8325339bc9a49cf2915bbf85e64e5",
# "uploadDate" : ISODate("2016-06-02T21:22:47.797Z"),
# "chunkSize" : 2096128,
# "filename" : "alpine-3.3.1-x86_64.iso",
# "metadata" : {
# "_auth" : {
# "owner" : null
# }
# },
# "aliases" : [ ],
# "contentType" : "application/x-iso9660-image"
# }
Hi @keyscores, I've tried ground db (and persistent minimongo too) on different collections that work with files but no success. For having offline data about files I usually create a parallel local collection on the client and use ground db on it. To populate the local collection I use an observe on a Mongo Cursor about original files, choosing what to copy or remove in the local collection every time a document is added, changed or removed in the file collection.
Obviously you can't have files in the local collection but file names, sizes and other stuff.
To have files offline you should download them, if you are on a Cordova client check out Cordova Plugin File Transfer.
Hope this helps...