Search code examples
parse-platform

Can I set a Parse Object Pointer with the ObjectID


I have a custom cloud code method to create a parse object. I'm doing that so I can validate the uniqueness of a few pointer objects, etc.

When I create the object I need to create, can I set the non validated pointers via the object id I get from the client side?

Something like object.set("user", "someuserid");

I'd like to avoid doing the extra find queries if I can when I already have the id.


Solution

  • You certainly can so long as you create a new pointer and assign the objectId.

    var Foo = Parse.Object.extend("Foo");
    var pointerToFoo = new Foo();
    pointerToFoo.id = "myObjectId";
    

    There is also a shortcut you can use called createWithoutData