0

Hi I'm using Parse Javascript API.

I was trying to save user objects as pointer of user array.

But result is

[{"__type":"Pointer","className":"_User","objectId":"a85SoYwEiE"}]

Could you advising me?

Here's my code

if (mentions.length > 0) {

    var query = new Parse.Query(Parse.User);
    query.containedIn("username", mentions);

    query.find().then(function(users) {

    // each of results will only have the selected fields available.
    var MensionNoti = Parse.Object.extend("Notification");
    var mentionNoti = new MensionNoti();

    //set by as CurrentUser
    mentionNoti.set("notiBy", commentBy);

    for (var i = 0; i < users.length; i++) {
        // This does not require a network access.
        //var user = users[i];
        var userPointer = Parse.User.createWithoutData(users[i].id) ;
        mentionNoti.addUnique("notiArray", userPointer);
    }

    //mentionNoti.set("notiArray", users);
    mentionNoti.set("type", "mention");
    //set Comment
    mentionNoti.set("messageText", comments);

    mentionNoti.set("checked", false);
    mentionNoti.set("postObj", results);
    mentionNoti.save();
    });
}

1 Answer 1

1

Try this. I haven't tested the code but technically, it should work.

var userArray = [];
for (var i = 0; i < users.length; i++) {
   // This does not require a network access.
   var userPointer = Parse.User.createWithoutData(users[i].id) ;
   userArray[i] = userPointer;
}
mentionNoti.addUnique("notiArray", userArray);
...
mentionNoti.save();

Hope this helps :)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.