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

object not found for update #597 #622

Closed
redblinkdevs opened this issue Feb 24, 2016 · 6 comments
Closed

object not found for update #597 #622

redblinkdevs opened this issue Feb 24, 2016 · 6 comments
Labels
type:question Support or code-level question

Comments

@redblinkdevs
Copy link

Hi @gfosco

As mentioned in issue #597 i am still getting object not found exception . let me know if you need more information

Thanks,
Parminder Ghuman

@redblinkdevs
Copy link
Author

Hi , Tried to save other object other than user in after save method of object
var UserMetadata = Parse.Object.extend("UserMetadata");
usermetadata = new UserMetadata();
usermetadata.set("userObject", request.user);
usermetadata.save(null, { useMasterKey: true }).then((userAgain) => {
console.log(userAgain);
}, (error) => {
console.log(error.message);
});

and get the following response
ParseObjectSubclass { className: 'UserMetadata', _objCount: 5, id: 'WOpVHVm44y' }

but not showing any record in mongo database;
db.UserMetadata.find(); returns empty set.

@gfosco
Copy link
Contributor

gfosco commented Feb 26, 2016

Are you sure you're checking the right database?... Since it succeeded like that, it's very unlikely to not be there...

@redblinkdevs
Copy link
Author

Yeah , NotificationTitle object created in same database and this method is written in its after save method.

@gfosco
Copy link
Contributor

gfosco commented Feb 26, 2016

Change to console.log(JSON.stringify(userAgain)); and lets see if it has a createdAt/updatedAt.

@redblinkdevs
Copy link
Author

Hi @gfosco ,
Sorry for late reply , I have just get latest code from github and run , it is saving object to mongo db, for user need to pass { useMasterKey: true } in cloud code and for other collection old code is working fine.
Is Parse.Cloud.useMasterKey(); is working in parse server any more ? becouse i have other code which saving users object also.

Thanks,
Parminder Ghuman

@gfosco
Copy link
Contributor

gfosco commented Mar 6, 2016

With Parse Server, and generally the Parse JS SDK, when running on Node, you can't have the concept of a 'current' user or a global flag for using the master key.

You have to pass it individually to each save or query call, as part of the options block. You pass either a session token or a flag to use the master key.

query.find({ useMasterKey: true }).then(...

query.find({ sessionToken: 'atoken' }).then(...

obj.save(null, { useMasterKey: true }).then(...

obj.save(null, { sessionToken: 'atoken' }).then(...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:question Support or code-level question
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants