Merge pull request #32267 from wazeHQ/backbone-relational-tojson

fix(@types/backbone-relational): Add toJSON options
This commit is contained in:
Benjamin Lichtman
2019-01-22 16:16:37 -08:00
committed by GitHub
2 changed files with 2 additions and 1 deletions
@@ -74,6 +74,7 @@ paul.get('livesIn'); // === ourHouse
// You can control which relations get serialized to JSON, using the 'includeInJSON'
// property on a Relation. Also, each object will only get serialized once to prevent loops.
alert(JSON.stringify(paul.get('user').toJSON(), null, '\t'));
alert(JSON.stringify(paul.get('user').toJSON({ option1: 'value1' }), null, '\t'));
// Load occupants 'person-2' and 'person-5', which don't exist yet, from the server
ourHouse.fetchRelated('occupants');
+1 -1
View File
@@ -34,7 +34,7 @@ declare module 'backbone' {
fetchRelated(key:string, options?:any, update?:boolean):any;
toJSON():any;
toJSON(options?: any):any;
static setup();