I am saving a object I call action to Parse
and I am getting the following error:
111 invalid type for key bookPointer, expected *Book, but got string
The code I use is:
action.set("bookPointer", "SPecEgZUhL");
action.save(null, {
success: function (data) {
// The object was saved successfully.
callback(true);
},
error: function (data,error) {
// The save failed.
// error is a Parse.Error with an error code and description.
console.log("Error: " + error.code + " " + error.message);
callback(false);
}
});
And my Book data looks like:
How do I get the pointer to my book, my *book in javascript?
Make sense to me that it should work fine with the objectId.
Thanks!
I am saving a object I call action to Parse.
and I am getting the following error:
111 invalid type for key bookPointer, expected *Book, but got string
The code I use is:
action.set("bookPointer", "SPecEgZUhL");
action.save(null, {
success: function (data) {
// The object was saved successfully.
callback(true);
},
error: function (data,error) {
// The save failed.
// error is a Parse.Error with an error code and description.
console.log("Error: " + error.code + " " + error.message);
callback(false);
}
});
And my Book data looks like:
How do I get the pointer to my book, my *book in javascript?
Make sense to me that it should work fine with the objectId.
Thanks!
Share Improve this question asked May 9, 2013 at 8:17 ArcayneArcayne 1,1861 gold badge15 silver badges35 bronze badges 2-
Does this work?
action.set("bookPointer", { __type: "Pointer", className: "Book", objectId: "SPecEgZUhL" });
– Dogbert Commented May 9, 2013 at 8:50 - @Dogbert, yes that works! Do you want to write it as an answer? – Arcayne Commented May 9, 2013 at 10:49
2 Answers
Reset to default 8A simpler/more strongly typed method would be:
// Assumes var Book = Parse.Object.extend("Book");
action.set("bookPointer", new Book({id: "SPecEgZUhL"}));
it's also not typically conventional to name columns after their type (e.g. "book" instead of "bookPointer")
As I said in the ment on the question, you can specify a pointer using a JS object like this in your case:
{
__type: "Pointer",
className: "Book",
objectId: "SPecEgZUhL"
}
Final code bees:
action.set("bookPointer", { __type: "Pointer", className: "Book", objectId: "SPecEgZUhL" });
Found it on the examples given on this page - https://www.parse./docs/rest