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

the id is not passed to the insert callback #27

Closed
drgorb opened this issue May 23, 2014 · 9 comments
Closed

the id is not passed to the insert callback #27

drgorb opened this issue May 23, 2014 · 9 comments

Comments

@drgorb
Copy link

drgorb commented May 23, 2014

When using collection.insert(myNewObject, function(err, id){... the id attribute is undefined

@drgorb
Copy link
Author

drgorb commented May 24, 2014

a workaround is to use Random.id() to set the value for _id before calling insert. In this case the id parameter is filled with the correct value. Here is an example:

  var newTeam = {
     _id: Random.id(),
     owner: Meteor.userId(),
     members: teamMembers,
     date: new Date()
  };
  Teams.insert(newTeam, function(err, _id) {
     if (!err) {
        WorkEntry.insert({
           team: _id,
           workEntries: []
        });
....

@raix
Copy link

raix commented May 24, 2014

Umm, seems strange, its just regular meteor.collection

@raix
Copy link

raix commented May 24, 2014

Btw. I'll have a closer look at this package soon - I'm finalizing a project where I created a very small offline db that stores in both local storage and on a S3 server (its a package Meteor client only app in cordova auth via Facebook)
This will be part of v2 of GroundDB

@scottburch
Copy link

Thanks @drgorb the workaround seems to work great. Did not know that the _id could be set in advance, this must be a new(ish) feature in Meteor.

@scottburch
Copy link

@drgorb seems to be a workaround for #34 as well.

@raix
Copy link

raix commented Sep 19, 2014

still a strange issue :) it should be basic meteor. could you try the new ground:db? @drgorb I've refactored so it uses async localstorage adapter - but we could in theory create a package for an other adapter and have grounddb use that instead.

raix pushed a commit that referenced this issue Sep 20, 2014
@raix
Copy link

raix commented Sep 20, 2014

please test this issue with ground:db at v0.0.3

@raix
Copy link

raix commented Sep 21, 2014

Cant meteor publish at the moment... Waiting for mdg

@raix
Copy link

raix commented Sep 21, 2014

Tracking it in #48

@raix raix closed this as completed Sep 21, 2014
@raix raix added the duplicate label Sep 21, 2014
raix pushed a commit that referenced this issue 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