Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No id returned by insert callback #48

Closed
IstoraMandiri opened this issue Sep 20, 2014 · 4 comments
Closed

No id returned by insert callback #48

IstoraMandiri opened this issue Sep 20, 2014 · 4 comments

Comments

@IstoraMandiri
Copy link

Looks like simply using meteor add ground:db will break CollectionFS file uploads, at least with GridFS.

After adding ground:db, whenever I upload files, the file object has an _id of undefined. Removing ground:db fixes this.

Without ground:db

  Template.test.events
    'change input' : (e) ->
      file = col.insert e.currentTarget.files[0]
      console.log 'uploaded', file._id # zt7JbYQjWwKNqtFEu

With ground:db

  Template.test.events
    'change input' : (e) ->
      file = col.insert e.currentTarget.files[0]
      console.log 'uploaded', file._id # undefined
@scottburch
Copy link

._id has been a problem with groundDB so far. See #27

I work around it by including _id in the object passed to Collection.insert() using collection2 and including an autovalue for _id using Random.id()

@IstoraMandiri
Copy link
Author

Thanks @scottburch, that workaround did the trick for me.

For others, to make it work with CFS, you need to upload a FS.File. Do the following:

Template.test.events
  'change input' : (e) ->
    file = new FS.File e.currentTarget.files[0]
    file._id = Random.id()
    uploadedFile = col.insert file
    console.log 'uploaded', uploadedFile._id # zt7JbYQjWwKNqtFEu

@raix
Copy link

raix commented Sep 20, 2014

Thanks guys!
Strange - I'd like to get to the bottom of this issue - ground:db is using a normal Meteor.collection - I can see that _id is missing from the method call it self though in the qa test - I'll have a closer look at this.

@raix raix closed this as completed in 4a09606 Sep 20, 2014
@raix
Copy link

raix commented Sep 21, 2014

This is still an odd issue, I'm trying to track down the true issue... Its not consistent, and the workaround should not be necessary..

I can replicate the issue in my qa test clients - but if I open the console and do db.insert({ foo: 'test' }, function(err, id) { console.log(id); }); it returns an id...

Also I can replicate this issue using a regular Meteor.Collection... In fact at the moment grounddb is using plain Meteor.Collection for this - So somethings weird is going on...

What I can see is that the Meteor.Collection.insert is not adding an _id in the data sent to Meteor.apply.

@raix raix reopened this Sep 21, 2014
@raix raix changed the title CollectionFS broken with ground:db [ground:db] no id returned by insert callback Sep 21, 2014
@raix raix changed the title [ground:db] no id returned by insert callback No id returned by insert callback Sep 21, 2014
raix pushed a commit that referenced this issue Sep 21, 2014
@raix raix closed this as completed Sep 21, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants