Skip to content

fix some issues / Update README.md #239

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 5, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 47 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -44,9 +44,9 @@ It's possible to add other parameters to work with your instance of Parse Server
clientKey: keyParseClientKey, // Required for some setups
debug: true, // When enabled, prints logs to console
liveQueryUrl: keyLiveQueryUrl, // Required if using LiveQuery
autoSendSessionId: true, // Some confurations require this to be true
autoSendSessionId: true, // Required for authentication and ACL
securityContext: securityContext, // Again, required for some setups
coreStore: await CoreStoreSharedPrefsImp.getInstance()); // Will use SharedPreferences instead of Sembast as an internal DB
coreStore: await CoreStoreSharedPrefsImp.getInstance()); // Local data storage method. Will use SharedPreferences instead of Sembast as an internal DB
```

## Objects
@@ -133,6 +133,17 @@ and to retrieve it
var dietPlan = DietPlan().fromPin('OBJECT ID OF OBJECT');
```

## Storage
We now have 2 types of storage, secure and unsecure. We currently rely on 2 third party options:

- SharedPreferences
- Sembast
Sembast offers secured storage, whilst SharePreferences wraps NSUserDefaults (on iOS) and SharedPreferences (on Android).

The storage method is defined in the parameter __coreStore__ in Parse().initialize

Check sample code for options

## Increment Counter values in objects
Retrieve it, call

@@ -578,6 +589,40 @@ final Map<String, String> params = <String, String>{'plan': 'paid'};
function.execute(parameters: params);
```

## Relation

The SDK supports Relation.

To add relation to object:

```dart
dietPlan.addRelation('fruits', [ParseObject("Fruits")..set("objectId", "XGadzYxnac")]);
```

To remove relation to object:

```dart
dietPlan.removeRelation('fruits', [ParseObject("Fruits")..set("objectId", "XGadzYxnac")]);
```

To Retrive a relation instance for user, call:
```dart
final relation = dietPlan.getRelation('fruits');
```

and then you can add a relation to the passed in object:
```
relation.add(dietPlan);
final result = await user.save();
```

To retrieve objects that are members of Relation field of a parent object:
```dart
QueryBuilder<ParseObject> query =
QueryBuilder<ParseObject>(ParseObject('Fruits'))
..whereRelatedTo('fruits', 'DietPlan', DietPlan.objectId);
```

## Other Features of this library
Main:
* Installation (View the example application)
4 changes: 2 additions & 2 deletions lib/src/network/parse_live_query.dart
Original file line number Diff line number Diff line change
@@ -49,7 +49,7 @@ class LiveQuery {
}

final String _className = query.object.parseClassName;
final keysToReturn = query.limiters['keys']?.split(',');
final List<String> keysToReturn = query.limiters['keys']?.split(',');
query.limiters.clear(); //Remove limits in LiveQuery
final String _where = query._buildQuery().replaceAll('where=', '');

@@ -139,7 +139,7 @@ class LiveQuery {
'query': <String, dynamic>{
'className': _className,
'where': _whereMap,
if (keysToReturn != null && keysToReturn.length > 0)
if (keysToReturn != null && keysToReturn.isNotEmpty)
'fields': keysToReturn
}
};
2 changes: 1 addition & 1 deletion lib/src/network/parse_query.dart
Original file line number Diff line number Diff line change
@@ -271,7 +271,7 @@ class QueryBuilder<T extends ParseObject> {
}

Future<ParseResponse> distinct(String className) async {
String queryString = "distinct=$className";
final String queryString = 'distinct=$className';
return object.distinct(queryString);
}