-
Notifications
You must be signed in to change notification settings - Fork 143
Add time between queries #268
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
Changes from 9 commits
053e7a2
32dc4cb
42244c0
8bed8aa
42bdb87
47f4915
538adb2
0706359
793a68d
bcad562
cead932
69901ef
f644d26
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,12 @@ Document result = await databases.createDocument( | |
databaseId: '<DATABASE_ID>', | ||
collectionId: '<COLLECTION_ID>', | ||
documentId: '<DOCUMENT_ID>', | ||
data: {}, | ||
data: { | ||
"username": "walter.obrien", | ||
"email": "[email protected]", | ||
"fullName": "Walter O'Brien", | ||
"age": 30, | ||
"isAdmin": false | ||
}, | ||
permissions: ["read("any")"], // optional | ||
); | ||
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -10,6 +10,12 @@ Row result = await tablesDB.createRow( | |||||||||
databaseId: '<DATABASE_ID>', | ||||||||||
tableId: '<TABLE_ID>', | ||||||||||
rowId: '<ROW_ID>', | ||||||||||
data: {}, | ||||||||||
data: { | ||||||||||
"username": "walter.obrien", | ||||||||||
"email": "[email protected]", | ||||||||||
"fullName": "Walter O'Brien", | ||||||||||
"age": 30, | ||||||||||
"isAdmin": false | ||||||||||
}, | ||||||||||
permissions: ["read("any")"], // optional | ||||||||||
); | ||||||||||
Comment on lines
20
to
21
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix invalid permissions syntax in Dart snippet. The current string quoting will not compile. Use the SDK helpers. Apply: - permissions: ["read("any")"], // optional
+ permissions: [Permission.read(Role.any())], // optional 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export 'src/client_browser.dart'; | ||
export 'src/client_browser.dart'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export 'src/client_io.dart'; | ||
export 'src/client_io.dart'; |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -11,11 +11,11 @@ class Query { | |||||||||||||||||||||||||||||||
Map<String, dynamic> toJson() { | ||||||||||||||||||||||||||||||||
final map = <String, dynamic>{'method': method}; | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
if (attribute != null) { | ||||||||||||||||||||||||||||||||
if(attribute != null) { | ||||||||||||||||||||||||||||||||
map['attribute'] = attribute; | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
if (values != null) { | ||||||||||||||||||||||||||||||||
if(values != null) { | ||||||||||||||||||||||||||||||||
map['values'] = values is List ? values : [values]; | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
|
@@ -26,7 +26,7 @@ class Query { | |||||||||||||||||||||||||||||||
String toString() => jsonEncode(toJson()); | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
/// Filter resources where [attribute] is equal to [value]. | ||||||||||||||||||||||||||||||||
/// | ||||||||||||||||||||||||||||||||
/// | ||||||||||||||||||||||||||||||||
/// [value] can be a single value or a list. If a list is used | ||||||||||||||||||||||||||||||||
/// the query will return resources where [attribute] is equal | ||||||||||||||||||||||||||||||||
/// to any of the values in the list. | ||||||||||||||||||||||||||||||||
|
@@ -111,6 +111,10 @@ class Query { | |||||||||||||||||||||||||||||||
static String createdAfter(String value) => | ||||||||||||||||||||||||||||||||
Query._('createdAfter', null, value).toString(); | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
/// Filter resources where document was created between [start] and [end] (inclusive). | ||||||||||||||||||||||||||||||||
static String createdBetween(String start, String end) => | ||||||||||||||||||||||||||||||||
Query._('createdBetween', null, [start, end]).toString(); | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
Comment on lines
+116
to
+119
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainFix createdBetween/updatedBetween to use supported operators. The server doesn’t expose “createdBetween”/“updatedBetween” operators. Use between() on $createdAt/$updatedAt instead to keep inclusive semantics documented in Queries. (appwrite.io) Apply: - /// Filter resources where document was created between [start] and [end] (inclusive).
- static String createdBetween(String start, String end) =>
- Query._('createdBetween', null, [start, end]).toString();
+ /// Filter resources where document was created between [start] and [end] (inclusive).
+ static String createdBetween(String start, String end) =>
+ between(r'$createdAt', start, end);
@@
- /// Filter resources where document was updated between [start] and [end] (inclusive).
- static String updatedBetween(String start, String end) =>
- Query._('updatedBetween', null, [start, end]).toString();
+ /// Filter resources where document was updated between [start] and [end] (inclusive).
+ static String updatedBetween(String start, String end) =>
+ between(r'$updatedAt', start, end); If tests assert the JSON method name equals "createdBetween"/"updatedBetween", update them to expect method "between" and attribute "$createdAt"/"$updatedAt", respectively. Also applies to: 126-129 🏁 Script executed: #!/bin/bash
# Search for existing between() method and createdBetween/updatedBetween in lib/query.dart
rg -nP --type=dart 'static String between' -n lib/query.dart || true
rg -nP --type=dart 'between\(' -n lib/query.dart || true
# Locate createdBetween and updatedBetween definitions
rg -nP --type=dart 'createdBetween' -n lib/query.dart || true
rg -nP --type=dart 'updatedBetween' -n lib/query.dart || true
# Inspect Query._ constructor to see supported operators
rg -nP --type=dart 'class Query\s*{' -n lib/query.dart -A5 -B0 || true
rg -nP --type=dart 'factory Query\._' -n lib/query.dart -A3 -B3 || true Length of output: 945 Use
🤖 Prompt for AI Agents
💡 Verification agent 🧩 Analysis chainRepo-wide verification for API compatibility. Update tests/usage to match the supported shape; remove any geometry/distance usages. Also applies to: 126-129, 178-224 🏁 Script executed: #!/bin/bash
# 1) Find usages of newly added helpers
rg -nP --type=dart -C2 '\b(createdBetween|updatedBetween|distance(Equal|NotEqual|GreaterThan|LessThan)|intersects|notIntersects|crosses|notCrosses|overlaps|notOverlaps|touches|notTouches)\s*\('
# 2) Show current JSON emitted by Query.createdBetween/updatedBetween
rg -nP -C3 'static\s+String\s+createdBetween|static\s+String\s+updatedBetween' lib/query.dart
# 3) Grep tests that assert method name/attribute for created/updated helpers
rg -nP -C2 'createdBetween|updatedBetween' test Length of output: 7187 Remove unsupported geometry/distance filter methods 🤖 Prompt for AI Agents
|
||||||||||||||||||||||||||||||||
/// Filter resources where document was updated before [value]. | ||||||||||||||||||||||||||||||||
static String updatedBefore(String value) => | ||||||||||||||||||||||||||||||||
Query._('updatedBefore', null, value).toString(); | ||||||||||||||||||||||||||||||||
|
@@ -119,6 +123,10 @@ class Query { | |||||||||||||||||||||||||||||||
static String updatedAfter(String value) => | ||||||||||||||||||||||||||||||||
Query._('updatedAfter', null, value).toString(); | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
/// Filter resources where document was updated between [start] and [end] (inclusive). | ||||||||||||||||||||||||||||||||
static String updatedBetween(String start, String end) => | ||||||||||||||||||||||||||||||||
Query._('updatedBetween', null, [start, end]).toString(); | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
static String or(List<String> queries) => Query._( | ||||||||||||||||||||||||||||||||
'or', | ||||||||||||||||||||||||||||||||
null, | ||||||||||||||||||||||||||||||||
|
@@ -144,14 +152,14 @@ class Query { | |||||||||||||||||||||||||||||||
Query._('orderDesc', attribute).toString(); | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
/// Return results before [id]. | ||||||||||||||||||||||||||||||||
/// | ||||||||||||||||||||||||||||||||
/// | ||||||||||||||||||||||||||||||||
/// Refer to the [Cursor Based Pagination](https://appwrite.io/docs/pagination#cursor-pagination) | ||||||||||||||||||||||||||||||||
/// docs for more information. | ||||||||||||||||||||||||||||||||
static String cursorBefore(String id) => | ||||||||||||||||||||||||||||||||
Query._('cursorBefore', null, id).toString(); | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
/// Return results after [id]. | ||||||||||||||||||||||||||||||||
/// | ||||||||||||||||||||||||||||||||
/// | ||||||||||||||||||||||||||||||||
/// Refer to the [Cursor Based Pagination](https://appwrite.io/docs/pagination#cursor-pagination) | ||||||||||||||||||||||||||||||||
/// docs for more information. | ||||||||||||||||||||||||||||||||
static String cursorAfter(String id) => | ||||||||||||||||||||||||||||||||
|
@@ -161,9 +169,57 @@ class Query { | |||||||||||||||||||||||||||||||
static String limit(int limit) => Query._('limit', null, limit).toString(); | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
/// Return results from [offset]. | ||||||||||||||||||||||||||||||||
/// | ||||||||||||||||||||||||||||||||
/// | ||||||||||||||||||||||||||||||||
/// Refer to the [Offset Pagination](https://appwrite.io/docs/pagination#offset-pagination) | ||||||||||||||||||||||||||||||||
/// docs for more information. | ||||||||||||||||||||||||||||||||
static String offset(int offset) => | ||||||||||||||||||||||||||||||||
Query._('offset', null, offset).toString(); | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
/// Filter resources where [attribute] is at a specific distance from the given coordinates. | ||||||||||||||||||||||||||||||||
static String distanceEqual(String attribute, List<dynamic> values, double distance, [bool meters = true]) => | ||||||||||||||||||||||||||||||||
Query._('distanceEqual', attribute, [values, distance, meters]).toString(); | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
/// Filter resources where [attribute] is not at a specific distance from the given coordinates. | ||||||||||||||||||||||||||||||||
static String distanceNotEqual(String attribute, List<dynamic> values, double distance, [bool meters = true]) => | ||||||||||||||||||||||||||||||||
Query._('distanceNotEqual', attribute, [values, distance, meters]).toString(); | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
/// Filter resources where [attribute] is at a distance greater than the specified value from the given coordinates. | ||||||||||||||||||||||||||||||||
static String distanceGreaterThan(String attribute, List<dynamic> values, double distance, [bool meters = true]) => | ||||||||||||||||||||||||||||||||
Query._('distanceGreaterThan', attribute, [values, distance, meters]).toString(); | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
/// Filter resources where [attribute] is at a distance less than the specified value from the given coordinates. | ||||||||||||||||||||||||||||||||
static String distanceLessThan(String attribute, List<dynamic> values, double distance, [bool meters = true]) => | ||||||||||||||||||||||||||||||||
Query._('distanceLessThan', attribute, [values, distance, meters]).toString(); | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Remove distance helpers — geospatial distance queries are not supported.* Appwrite queries don’t support distanceEqual/NotEqual/GreaterThan/LessThan operators today; recommended patterns use bounding-box comparisons on lat/long attributes client-side. Keep these out to avoid shipping unusable APIs. (appwrite.io, dev.to) Apply: - /// Filter resources where [attribute] is at a specific distance from the given coordinates.
- static String distanceEqual(String attribute, List<dynamic> values, double distance, [bool meters = true]) =>
- Query._('distanceEqual', attribute, [values, distance, meters]).toString();
-
- /// Filter resources where [attribute] is not at a specific distance from the given coordinates.
- static String distanceNotEqual(String attribute, List<dynamic> values, double distance, [bool meters = true]) =>
- Query._('distanceNotEqual', attribute, [values, distance, meters]).toString();
-
- /// Filter resources where [attribute] is at a distance greater than the specified value from the given coordinates.
- static String distanceGreaterThan(String attribute, List<dynamic> values, double distance, [bool meters = true]) =>
- Query._('distanceGreaterThan', attribute, [values, distance, meters]).toString();
-
- /// Filter resources where [attribute] is at a distance less than the specified value from the given coordinates.
- static String distanceLessThan(String attribute, List<dynamic> values, double distance, [bool meters = true]) =>
- Query._('distanceLessThan', attribute, [values, distance, meters]).toString(); Alternatively, gate them with @deprecated and throw UnsupportedError immediately with a link to docs. 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||||||||||||||||||||||||||||
/// Filter resources where [attribute] intersects with the given geometry. | ||||||||||||||||||||||||||||||||
static String intersects(String attribute, List<dynamic> values) => | ||||||||||||||||||||||||||||||||
Query._('intersects', attribute, values).toString(); | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
/// Filter resources where [attribute] does not intersect with the given geometry. | ||||||||||||||||||||||||||||||||
static String notIntersects(String attribute, List<dynamic> values) => | ||||||||||||||||||||||||||||||||
Query._('notIntersects', attribute, values).toString(); | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
/// Filter resources where [attribute] crosses the given geometry. | ||||||||||||||||||||||||||||||||
static String crosses(String attribute, List<dynamic> values) => | ||||||||||||||||||||||||||||||||
Query._('crosses', attribute, values).toString(); | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
/// Filter resources where [attribute] does not cross the given geometry. | ||||||||||||||||||||||||||||||||
static String notCrosses(String attribute, List<dynamic> values) => | ||||||||||||||||||||||||||||||||
Query._('notCrosses', attribute, values).toString(); | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
/// Filter resources where [attribute] overlaps with the given geometry. | ||||||||||||||||||||||||||||||||
static String overlaps(String attribute, List<dynamic> values) => | ||||||||||||||||||||||||||||||||
Query._('overlaps', attribute, values).toString(); | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
/// Filter resources where [attribute] does not overlap with the given geometry. | ||||||||||||||||||||||||||||||||
static String notOverlaps(String attribute, List<dynamic> values) => | ||||||||||||||||||||||||||||||||
Query._('notOverlaps', attribute, values).toString(); | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
/// Filter resources where [attribute] touches the given geometry. | ||||||||||||||||||||||||||||||||
static String touches(String attribute, List<dynamic> values) => | ||||||||||||||||||||||||||||||||
Query._('touches', attribute, values).toString(); | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
/// Filter resources where [attribute] does not touch the given geometry. | ||||||||||||||||||||||||||||||||
static String notTouches(String attribute, List<dynamic> values) => | ||||||||||||||||||||||||||||||||
Query._('notTouches', attribute, values).toString(); | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export 'src/realtime_browser.dart'; | ||
export 'src/realtime_browser.dart'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export 'src/realtime_io.dart'; | ||
export 'src/realtime_io.dart'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -63,4 +63,4 @@ class Role { | |
static String label(String name) { | ||
return 'label:$name'; | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix invalid permissions syntax in Dart snippet.
Use typed builders to avoid quoting issues.
Apply:
📝 Committable suggestion
🤖 Prompt for AI Agents