From 75578070027be8f3166198819b678128ee28aa10 Mon Sep 17 00:00:00 2001 From: Diamond Lewis Date: Wed, 24 Jul 2019 12:28:00 -0500 Subject: [PATCH 1/2] Documentation for isDataAvailable --- _includes/js/objects.md | 8 ++++++++ _includes/php/objects.md | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/_includes/js/objects.md b/_includes/js/objects.md index 2bdfc8cfc..2206bdcde 100644 --- a/_includes/js/objects.md +++ b/_includes/js/objects.md @@ -217,6 +217,14 @@ myObject.fetch().then((myObject) => { }); ``` +If you need to check if an object has been fetched, you can call the `isDataAvailable()` method: + +```javascript +if (myObject.isDataAvailable()) { + await myObject.fetch(); +} +``` + ## Updating Objects Updating an object is simple. Just set some new data on it and call the save method. For example: diff --git a/_includes/php/objects.md b/_includes/php/objects.md index 903636f78..d74e30acf 100644 --- a/_includes/php/objects.md +++ b/_includes/php/objects.md @@ -83,6 +83,14 @@ If you need to refresh an object you already have with the latest data that $gameScore->fetch(); ``` +If you need to check if an object has been fetched, you can use `isDataAvailable() + +```php +if ($gameScore->isDataAvailable()) { + $gameScore->fetch(); +} +``` + ## Updating Objects Updating an object is simple. Just set some new data on it and call the save method. For example: From 0ae950dcf03c1b6cc26d27b3b2aea3c5cbf699d2 Mon Sep 17 00:00:00 2001 From: Diamond Lewis Date: Wed, 24 Jul 2019 13:08:50 -0500 Subject: [PATCH 2/2] fix syntax --- _includes/js/objects.md | 2 +- _includes/php/objects.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/_includes/js/objects.md b/_includes/js/objects.md index 2206bdcde..fee0c513f 100644 --- a/_includes/js/objects.md +++ b/_includes/js/objects.md @@ -220,7 +220,7 @@ myObject.fetch().then((myObject) => { If you need to check if an object has been fetched, you can call the `isDataAvailable()` method: ```javascript -if (myObject.isDataAvailable()) { +if (!myObject.isDataAvailable()) { await myObject.fetch(); } ``` diff --git a/_includes/php/objects.md b/_includes/php/objects.md index d74e30acf..53835bf40 100644 --- a/_includes/php/objects.md +++ b/_includes/php/objects.md @@ -83,10 +83,10 @@ If you need to refresh an object you already have with the latest data that $gameScore->fetch(); ``` -If you need to check if an object has been fetched, you can use `isDataAvailable() +If you need to check if an object has been fetched, you can call the `isDataAvailable()` method: ```php -if ($gameScore->isDataAvailable()) { +if (!$gameScore->isDataAvailable()) { $gameScore->fetch(); } ```