I am saving a object I call action to Parse.com
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!
A 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 (eg "book" instead of "bookPointer")
As I said in the comment 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 becomes:
action.set("bookPointer", { __type: "Pointer", className: "Book", objectId: "SPecEgZUhL" });
Found it on the examples given on this page - https://www.parse.com/docs/rest
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.