Skip to content

Wrong format of user object saved in MongoDB after pasing thru beforeSave #589

Closed
@mchun

Description

@mchun

This is my code for creating a new post:

 app.post('/',requireUser, function(req, res) {
    var parseUserMe = new Parse.User();
    parseUserMe.id = req.user.id;
    var post = new Post();
    post.set("Desc", req.body.Desc);
    post.set("createdBy", parseUserMe);
    post.save().then(function(post) {
      res.json({ id: post.id });
    }, function(error) {
      res.json({ error: error });
    });
  });

But inside MongoDB, the createdBy field is saved as

    "_p_createdBy": {
        "score": 59,
        "updatedAt": {
            "$date": "2016-02-23T04:06:29.402Z"
        },
        "objectId": "SPtdQePtm2",
        "__type": "Object",
        "className": "_User"
    },

instead of this:

"_p_createdBy": "_User$SPtdQePtm2",

which caused the Dashboard to crash and showed the following error on the server:

Uncaught internal server error. [TypeError: mongoObject[key].split is not a function] TypeError: mongoObject[key].split is not a function

Metadata

Metadata

Assignees

No one assigned

    Labels

    type:bugImpaired feature or lacking behavior that is likely assumed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions