Not sure if its a bug or a misunderstanding of how things are meant to work:
- disable single instance mode
- Create a new parse object (or query one from the server) and populate properties
- Make a copy of the object (e.g. if you were editing the properties on a form and wanted the option to save/discard changes)
- Copy is empty ....
using parse-js-sdk 1.9.2 and angular 1.4.8
//comment out the following line and it works ok
Parse.Object.disableSingleInstance();
var parseObjClass = Parse.Object.extend('Comments', {
// Instance methods
initialize: function (attrs, options) {}
},
{});
['name', 'desc'].forEach(function (item) {
Object.defineProperty(parseObjClass.prototype, item, {
get: function () {
return this.get(item);
},
set: function (aValue) {
return this.set(item, aValue);
}
});
});
var parseObj = new parseObjClass();
parseObj.name = 'Hello World'
parseObj.desc = 'Test Object'
console.log('original is ' + JSON.stringify(parseObj));
//--> original is {"name":"Hello World","desc":"Test Object"}
var objCopy = angular.copy(parseObj);
console.log('copy is ' + JSON.stringify(objCopy));
//--> copy is {}
Here is a plunker illustrating https://plnkr.co/edit/UjWe9dl6D6Qkx9ihBSMC
background : we are using disableSingleInstance mode because we have a mobile app and a a web app that can interact with the same database rows (timesheet data) and were having problems with the js-sdk not always having the latest version of the data...