From 7bfb5873fcdb7a5625e8baea12b51aa2564b557c Mon Sep 17 00:00:00 2001 From: Perceval Archimbaud Date: Tue, 20 Feb 2018 16:41:56 +0100 Subject: [PATCH 1/2] Update ParseObject interface by adding revert() method --- types/parse/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/parse/index.d.ts b/types/parse/index.d.ts index d186211983..260f3fb4a0 100644 --- a/types/parse/index.d.ts +++ b/types/parse/index.d.ts @@ -377,6 +377,7 @@ declare namespace Parse { previousAttributes(): any; relation(attr: string): Relation; remove(attr: string, item: any): any; + revert(): void; save(attrs?: { [key: string]: any } | null, options?: Object.SaveOptions): Promise; save(key: string, value: any, options?: Object.SaveOptions): Promise; save(attrs: object, options?: Object.SaveOptions): Promise; From 93802181103133e68bdb85eabb460c6104eea694 Mon Sep 17 00:00:00 2001 From: Perceval Archimbaud Date: Tue, 20 Feb 2018 17:22:09 +0100 Subject: [PATCH 2/2] Update test with revert --- types/parse/parse-tests.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/types/parse/parse-tests.ts b/types/parse/parse-tests.ts index 06ec062880..9f08c3530b 100644 --- a/types/parse/parse-tests.ts +++ b/types/parse/parse-tests.ts @@ -288,7 +288,13 @@ function test_user_acl_roles() { game.setACL(new Parse.ACL(Parse.User.current())); game.save().then((game: Game) => { }); game.save(null, { useMasterKey: true }); - game.save({ score: '10' }, { useMasterKey: true }); + game.save({ score: '10' }, { useMasterKey: true }).then(function (game) { + // Update game then revert it to the last saved state. + game.set("score", '20'); + game.revert(); + }, function (error) { + // The save failed + }); const groupACL = new Parse.ACL();