Skip to content

Commit d130a54

Browse files
authored
Merge pull request #41 from phillwiggins/develop
Develop
2 parents 00e6a16 + e4b6cd9 commit d130a54

File tree

8 files changed

+158
-148
lines changed

8 files changed

+158
-148
lines changed

.idea/workspace.xml

+114-127
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 1.0.8
2+
Fixed some queries
3+
14
## 1.0.7
25

36
Some items now return a response rather than a ParseObject

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Want to get involved? Join our Slack channel and help out! (http://flutter-parse
1313
To install, either add to your pubspec.yaml
1414
```
1515
dependencies:
16-
parse_server_sdk: ^1.0.7
16+
parse_server_sdk: ^1.0.8
1717
```
1818
or clone this repository and add to your project. As this is an early development with multiple contributors, it is probably best to download/clone and keep updating as an when a new feature is added.
1919

example/lib/main.dart

+8-8
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,13 @@ class _MyAppState extends State<MyApp> {
5151
}
5252

5353
runTestQueries() {
54-
createItem();
55-
getAllItems();
56-
getAllItemsByName();
57-
getSingleItem();
54+
//createItem();
55+
//getAllItems();
56+
//getAllItemsByName();
57+
//getSingleItem();
5858
query();
59-
function();
60-
initUser();
59+
//function();
60+
//initUser();
6161
}
6262

6363
void createItem() async {
@@ -112,7 +112,6 @@ class _MyAppState extends State<MyApp> {
112112

113113
// shows example of retrieving a pin
114114
var newDietPlanFromPin = DietPlan().fromPin('R5EonpUDWy');
115-
116115
if (newDietPlanFromPin != null) print('Retreiving from pin worked!');
117116

118117
} else {
@@ -122,7 +121,8 @@ class _MyAppState extends State<MyApp> {
122121

123122
void query() async {
124123
var queryBuilder = QueryBuilder<DietPlan>(DietPlan())
125-
..whereContains(DietPlan.keyName, "eto");
124+
..whereContains(DietPlan.keyName, "iet")
125+
..keysToReturn([DietPlan.keyName]);
126126

127127
var apiResponse = await queryBuilder.query();
128128

lib/src/network/parse_query.dart

+20-7
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,12 @@ class QueryBuilder<T extends ParseObject> {
4949
/// [String] keys will only return the columns of a result you want the data for,
5050
/// this is useful for large objects
5151
void keysToReturn(List<String> keys){
52-
limiters["keys"] = keys.toString();
52+
limiters["keys"] = concatArray(keys);
5353
}
5454

5555
/// Includes other ParseObjects stored as a Pointer
56-
void includeObject(String objectType){
57-
limiters["include"] = objectType;
56+
void includeObject(List<String> objectTypes){
57+
limiters["include"] = concatArray(objectTypes);
5858
}
5959

6060
/// Returns an object where the [String] column starts with [value]
@@ -148,15 +148,15 @@ class QueryBuilder<T extends ParseObject> {
148148
/// Performs a search to see if [String] contains other string
149149
void whereContains(String column, String value, {bool caseSensitive: false}) {
150150
if (caseSensitive) {
151-
queries.add(MapEntry(_SINGLE_QUERY, '\"$column\":{\"\$regex\": \"$query\"}'));
151+
queries.add(MapEntry(_SINGLE_QUERY, '\"$column\":{\"\$regex\": \"$value\"}'));
152152
} else {
153-
queries.add(MapEntry(_SINGLE_QUERY, '\"$column\":{\"\$regex\": \"$query\", \"\$options\": \"i\"}'));
153+
queries.add(MapEntry(_SINGLE_QUERY, '\"$column\":{\"\$regex\": \"$value\", \"\$options\": \"i\"}'));
154154
}
155155
}
156156

157157
/// Powerful search for containing whole words. This search is much quicker than regex and can search for whole words including wether they are case sensitive or not.
158158
/// This search can also order by the score of the search
159-
void textContainsWholeWord(String column, String query, {bool caseSensitive: false, bool orderByScore: true}){
159+
void whereContainsWholeWord(String column, String query, {bool caseSensitive: false, bool orderByScore: true}){
160160
queries.add(MapEntry(_SINGLE_QUERY, '\"$column\":{\"\$text\":{\"\$search\":{\"\$term\": \"$query\", \"\$caseSensitive\": $caseSensitive }}}'));
161161
if (orderByScore) orderByDescending('score');
162162
}
@@ -177,7 +177,6 @@ class QueryBuilder<T extends ParseObject> {
177177

178178
/// Runs through all queries and adds them to a query string
179179
String buildQueries(List<MapEntry> queries) {
180-
181180
String queryBuilder = "";
182181

183182
for (var item in queries) {
@@ -191,6 +190,20 @@ class QueryBuilder<T extends ParseObject> {
191190
return queryBuilder;
192191
}
193192

193+
String concatArray(List<String> queries) {
194+
String queryBuilder = "";
195+
196+
for (var item in queries) {
197+
if (item == queries.first) {
198+
queryBuilder += item;
199+
} else {
200+
queryBuilder += ",$item";
201+
}
202+
}
203+
204+
return queryBuilder;
205+
}
206+
194207
/// Creates a query param using the column, the value and the queryOperator
195208
/// that the column and value are being queried against
196209
MapEntry _buildQueryWithColumnValueAndOperator(MapEntry columnAndValue, String queryOperator) {

lib/src/objects/parse_object.dart

+10-2
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,16 @@ class ParseObject extends ParseBase implements ParseCloneable {
170170
/// Can be used to create custom queries
171171
Future<ParseResponse> query(String query) async {
172172
try {
173-
var uri = "${ParseCoreData().serverUrl}$_path?$query";
174-
var result = await _client.get(uri);
173+
174+
Uri tempUri = Uri.parse(ParseCoreData().serverUrl);
175+
176+
Uri url = Uri(
177+
scheme: tempUri.scheme,
178+
host: tempUri.host,
179+
path: "${tempUri.path}$_path",
180+
query: query);
181+
182+
var result = await _client.get(url);
175183
return handleResponse(result, ParseApiRQ.query);
176184
} on Exception catch (e) {
177185
return handleException(e, ParseApiRQ.query);

lib/src/objects/parse_user.dart

+1-2
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,7 @@ class ParseUser extends ParseObject implements ParseCloneable {
7474
host: tempUri.host,
7575
path: "${tempUri.path}$keyEndPointUserName");
7676

77-
final response = await _client
78-
.get(uri, headers: {keyHeaderSessionToken: _client.data.sessionId});
77+
final response = await _client.get(uri, headers: {keyHeaderSessionToken: _client.data.sessionId});
7978
return _handleResponse(response, ParseApiRQ.currentUser);
8079
} on Exception catch (e) {
8180
return _handleException(e, ParseApiRQ.currentUser);

pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: parse_server_sdk
22
description: Flutter plugin for Parse Server, (https://parseplatform.org), (https://back4app.com)
3-
version: 1.0.7
3+
version: 1.0.8
44
homepage: https://github.com/phillwiggins/flutter_parse_sdk
55
author: PhillWiggins <phill.wiggins@gmail.com>
66

0 commit comments

Comments
 (0)