Skip to content

Commit aa8b027

Browse files
authored
docs: update relative QueryConstraint support for Postgres (#305)
* docs: update relative QueryConstraint support for Postgres * Update Playgrounds
1 parent 1636285 commit aa8b027

File tree

7 files changed

+25
-26
lines changed

7 files changed

+25
-26
lines changed

CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ __Improvements__
308308
- Append instead of replace when using query select, exclude, include, and fields ([#155](https://github.com/parse-community/Parse-Swift/pull/155)), thanks to [Corey Baker](https://github.com/cbaker6).
309309

310310
__Fixes__
311-
- Transactions currently don't work when using mongoDB(postgres does work) on the parse-server. Internal use of transactions are disabled by default. If you want the Swift SDK to use transactions internally, you need to set useTransactionsInternally=true when configuring the client. It is recommended not to use transactions if you are using mongoDB until it's fixed on the server ([#158](https://github.com/parse-community/Parse-Swift/pull/158)), thanks to [Corey Baker](https://github.com/cbaker6).
311+
- Transactions currently don't work when using MongoDB(postgres does work) on the parse-server. Internal use of transactions are disabled by default. If you want the Swift SDK to use transactions internally, you need to set useTransactionsInternally=true when configuring the client. It is recommended not to use transactions if you are using MongoDB until it's fixed on the server ([#158](https://github.com/parse-community/Parse-Swift/pull/158)), thanks to [Corey Baker](https://github.com/cbaker6).
312312

313313
### 1.8.0
314314
[Full Changelog](https://github.com/parse-community/Parse-Swift/compare/1.7.2...1.8.0)

ParseSwift.playground/Pages/2 - Finding Objects.xcplaygroundpage/Contents.swift

+2-3
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ query.first { results in
112112
}
113113
}
114114

115-
//: Query based on relative time. Have to be using mongoDB.
116-
/*let queryRelative = GameScore.query(relative("createdAt" < "10 minutes ago"))
115+
//: Query based on relative time.
116+
let queryRelative = GameScore.query(relative("createdAt" < "10 minutes ago"))
117117
queryRelative.find { results in
118118
switch results {
119119
case .success(let scores):
@@ -124,7 +124,6 @@ queryRelative.find { results in
124124
assertionFailure("Error querying: \(error)")
125125
}
126126
}
127-
*/
128127

129128
let querySelect = query.select("score")
130129
querySelect.first { results in

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ A pure Swift library that gives you access to the powerful Parse Server backend
2828

2929
For more information about the Parse Platform and its features, see the public [documentation][docs]. The ParseSwift SDK is not a port of the [Parse-SDK-iOS-OSX SDK](https://github.com/parse-community/Parse-SDK-iOS-OSX) and though some of it may feel familiar, it is not backwards compatible and is designed with a new philosophy. For more details visit the [api documentation](http://parseplatform.org/Parse-Swift/api/).
3030

31-
To learn how to use or experiment with ParseSwift, you can run and edit the [ParseSwift.playground](https://github.com/parse-community/Parse-Swift/tree/main/ParseSwift.playground/Pages). You can use the parse-server in [this repo](https://github.com/netreconlab/parse-hipaa/tree/parse-swift) which has docker compose files (`docker-compose up` gives you a working server) configured to connect with the playground files, has [Parse Dashboard](https://github.com/parse-community/parse-dashboard), and can be used with mongoDB or PostgreSQL.
31+
To learn how to use or experiment with ParseSwift, you can run and edit the [ParseSwift.playground](https://github.com/parse-community/Parse-Swift/tree/main/ParseSwift.playground/Pages). You can use the parse-server in [this repo](https://github.com/netreconlab/parse-hipaa/tree/parse-swift) which has docker compose files (`docker-compose up` gives you a working server) configured to connect with the playground files, has [Parse Dashboard](https://github.com/parse-community/parse-dashboard), and can be used with MongoDB or PostgreSQL.
3232

3333
---
3434

Sources/ParseSwift/Types/Query+async.swift

+5-5
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public extension Query {
3131
- parameter options: A set of header options sent to the server. Defaults to an empty set.
3232
- note: An explain query will have many different underlying types. Since Swift is a strongly
3333
typed language, a developer should specify the type expected to be decoded which will be
34-
different for mongoDB and PostgreSQL. One way around this is to use a type-erased wrapper
34+
different for MongoDB and PostgreSQL. One way around this is to use a type-erased wrapper
3535
such as the [AnyCodable](https://github.com/Flight-School/AnyCodable) package.
3636
- returns: An array of ParseObjects.
3737
- throws: An error of type `ParseError`.
@@ -78,7 +78,7 @@ public extension Query {
7878
Query plan information for getting an object *asynchronously*.
7979
- note: An explain query will have many different underlying types. Since Swift is a strongly
8080
typed language, a developer should specify the type expected to be decoded which will be
81-
different for mongoDB and PostgreSQL. One way around this is to use a type-erased wrapper
81+
different for MongoDB and PostgreSQL. One way around this is to use a type-erased wrapper
8282
such as the [AnyCodable](https://github.com/Flight-School/AnyCodable) package.
8383
- parameter options: A set of header options sent to the server. Defaults to an empty set.
8484
- returns: An array of ParseObjects.
@@ -108,7 +108,7 @@ public extension Query {
108108
Query plan information for counting objects *asynchronously*.
109109
- note: An explain query will have many different underlying types. Since Swift is a strongly
110110
typed language, a developer should specify the type expected to be decoded which will be
111-
different for mongoDB and PostgreSQL. One way around this is to use a type-erased wrapper
111+
different for MongoDB and PostgreSQL. One way around this is to use a type-erased wrapper
112112
such as the [AnyCodable](https://github.com/Flight-School/AnyCodable) package.
113113
- parameter explain: Used to toggle the information on the query plan.
114114
- parameter options: A set of header options sent to the server. Defaults to an empty set.
@@ -144,7 +144,7 @@ public extension Query {
144144
- requires: `.useMasterKey` has to be available.
145145
- note: An explain query will have many different underlying types. Since Swift is a strongly
146146
typed language, a developer should specify the type expected to be decoded which will be
147-
different for mongoDB and PostgreSQL. One way around this is to use a type-erased wrapper
147+
different for MongoDB and PostgreSQL. One way around this is to use a type-erased wrapper
148148
such as the [AnyCodable](https://github.com/Flight-School/AnyCodable) package.
149149
- parameter pipeline: A pipeline of stages to process query.
150150
- parameter options: A set of header options sent to the server. Defaults to an empty set.
@@ -182,7 +182,7 @@ public extension Query {
182182
- requires: `.useMasterKey` has to be available.
183183
- note: An explain query will have many different underlying types. Since Swift is a strongly
184184
typed language, a developer should specify the type expected to be decoded which will be
185-
different for mongoDB and PostgreSQL. One way around this is to use a type-erased wrapper
185+
different for MongoDB and PostgreSQL. One way around this is to use a type-erased wrapper
186186
such as the [AnyCodable](https://github.com/Flight-School/AnyCodable) package.
187187
- parameter key: A field to find distinct values.
188188
- parameter options: A set of header options sent to the server. Defaults to an empty set.

Sources/ParseSwift/Types/Query+combine.swift

+5-5
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public extension Query {
3131
- parameter options: A set of header options sent to the server. Defaults to an empty set.
3232
- note: An explain query will have many different underlying types. Since Swift is a strongly
3333
typed language, a developer should specify the type expected to be decoded which will be
34-
different for mongoDB and PostgreSQL. One way around this is to use a type-erased wrapper
34+
different for MongoDB and PostgreSQL. One way around this is to use a type-erased wrapper
3535
such as the [AnyCodable](https://github.com/Flight-School/AnyCodable) package.
3636
- returns: A publisher that eventually produces a single value and then finishes or fails.
3737
*/
@@ -76,7 +76,7 @@ public extension Query {
7676
Query plan information for getting an object *asynchronously* and publishes when complete.
7777
- note: An explain query will have many different underlying types. Since Swift is a strongly
7878
typed language, a developer should specify the type expected to be decoded which will be
79-
different for mongoDB and PostgreSQL. One way around this is to use a type-erased wrapper
79+
different for MongoDB and PostgreSQL. One way around this is to use a type-erased wrapper
8080
such as the [AnyCodable](https://github.com/Flight-School/AnyCodable) package.
8181
- parameter options: A set of header options sent to the server. Defaults to an empty set.
8282
- returns: A publisher that eventually produces a single value and then finishes or fails.
@@ -104,7 +104,7 @@ public extension Query {
104104
Query plan information for counting objects *asynchronously* and publishes when complete.
105105
- note: An explain query will have many different underlying types. Since Swift is a strongly
106106
typed language, a developer should specify the type expected to be decoded which will be
107-
different for mongoDB and PostgreSQL. One way around this is to use a type-erased wrapper
107+
different for MongoDB and PostgreSQL. One way around this is to use a type-erased wrapper
108108
such as the [AnyCodable](https://github.com/Flight-School/AnyCodable) package.
109109
- parameter explain: Used to toggle the information on the query plan.
110110
- parameter options: A set of header options sent to the server. Defaults to an empty set.
@@ -138,7 +138,7 @@ public extension Query {
138138
- requires: `.useMasterKey` has to be available.
139139
- note: An explain query will have many different underlying types. Since Swift is a strongly
140140
typed language, a developer should specify the type expected to be decoded which will be
141-
different for mongoDB and PostgreSQL. One way around this is to use a type-erased wrapper
141+
different for MongoDB and PostgreSQL. One way around this is to use a type-erased wrapper
142142
such as the [AnyCodable](https://github.com/Flight-School/AnyCodable) package.
143143
- parameter pipeline: A pipeline of stages to process query.
144144
- parameter options: A set of header options sent to the server. Defaults to an empty set.
@@ -174,7 +174,7 @@ public extension Query {
174174
- requires: `.useMasterKey` has to be available.
175175
- note: An explain query will have many different underlying types. Since Swift is a strongly
176176
typed language, a developer should specify the type expected to be decoded which will be
177-
different for mongoDB and PostgreSQL. One way around this is to use a type-erased wrapper
177+
different for MongoDB and PostgreSQL. One way around this is to use a type-erased wrapper
178178
such as the [AnyCodable](https://github.com/Flight-School/AnyCodable) package.
179179
- parameter key: A field to find distinct values.
180180
- parameter options: A set of header options sent to the server. Defaults to an empty set.

Sources/ParseSwift/Types/Query.swift

+10-10
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ extension Query: Queryable {
379379
sets an error if there was one.
380380
- note: An explain query will have many different underlying types. Since Swift is a strongly
381381
typed language, a developer should specify the type expected to be decoded which will be
382-
different for mongoDB and PostgreSQL. One way around this is to use a type-erased wrapper
382+
different for MongoDB and PostgreSQL. One way around this is to use a type-erased wrapper
383383
such as the [AnyCodable](https://github.com/Flight-School/AnyCodable) package.
384384
- parameter options: A set of header options sent to the server. Defaults to an empty set.
385385
- throws: An error of type `ParseError`.
@@ -420,7 +420,7 @@ extension Query: Queryable {
420420
Query plan information for finding objects *asynchronously* and calls the given block with the results.
421421
- note: An explain query will have many different underlying types. Since Swift is a strongly
422422
typed language, a developer should specify the type expected to be decoded which will be
423-
different for mongoDB and PostgreSQL. One way around this is to use a type-erased wrapper
423+
different for MongoDB and PostgreSQL. One way around this is to use a type-erased wrapper
424424
such as the [AnyCodable](https://github.com/Flight-School/AnyCodable) package.
425425
- parameter options: A set of header options sent to the server. Defaults to an empty set.
426426
- parameter callbackQueue: The queue to return to after completion. Default value of .main.
@@ -540,7 +540,7 @@ extension Query: Queryable {
540540
- warning: This method mutates the query. It will reset the limit to `1`.
541541
- note: An explain query will have many different underlying types. Since Swift is a strongly
542542
typed language, a developer should specify the type expected to be decoded which will be
543-
different for mongoDB and PostgreSQL. One way around this is to use a type-erased wrapper
543+
different for MongoDB and PostgreSQL. One way around this is to use a type-erased wrapper
544544
such as the [AnyCodable](https://github.com/Flight-School/AnyCodable) package.
545545
- parameter options: A set of header options sent to the server. Defaults to an empty set.
546546
- throws: An error of type `ParseError`.
@@ -587,7 +587,7 @@ extension Query: Queryable {
587587
- warning: This method mutates the query. It will reset the limit to `1`.
588588
- note: An explain query will have many different underlying types. Since Swift is a strongly
589589
typed language, a developer should specify the type expected to be decoded which will be
590-
different for mongoDB and PostgreSQL. One way around this is to use a type-erased wrapper
590+
different for MongoDB and PostgreSQL. One way around this is to use a type-erased wrapper
591591
such as the [AnyCodable](https://github.com/Flight-School/AnyCodable) package.
592592
- parameter options: A set of header options sent to the server. Defaults to an empty set.
593593
- parameter callbackQueue: The queue to return to after completion. Default value of `.main`.
@@ -630,7 +630,7 @@ extension Query: Queryable {
630630
constructed query and sets an error if there was one.
631631
- note: An explain query will have many different underlying types. Since Swift is a strongly
632632
typed language, a developer should specify the type expected to be decoded which will be
633-
different for mongoDB and PostgreSQL. One way around this is to use a type-erased wrapper
633+
different for MongoDB and PostgreSQL. One way around this is to use a type-erased wrapper
634634
such as the [AnyCodable](https://github.com/Flight-School/AnyCodable) package.
635635
- parameter options: A set of header options sent to the server. Defaults to an empty set.
636636
- throws: An error of type `ParseError`.
@@ -670,7 +670,7 @@ extension Query: Queryable {
670670
Query plan information for counting objects *asynchronously* and calls the given block with the counts.
671671
- note: An explain query will have many different underlying types. Since Swift is a strongly
672672
typed language, a developer should specify the type expected to be decoded which will be
673-
different for mongoDB and PostgreSQL. One way around this is to use a type-erased wrapper
673+
different for MongoDB and PostgreSQL. One way around this is to use a type-erased wrapper
674674
such as the [AnyCodable](https://github.com/Flight-School/AnyCodable) package.
675675
- parameter options: A set of header options sent to the server. Defaults to an empty set.
676676
- parameter callbackQueue: The queue to return to after completion. Default value of `.main`.
@@ -791,7 +791,7 @@ extension Query: Queryable {
791791
- requires: `.useMasterKey` has to be available.
792792
- note: An explain query will have many different underlying types. Since Swift is a strongly
793793
typed language, a developer should specify the type expected to be decoded which will be
794-
different for mongoDB and PostgreSQL. One way around this is to use a type-erased wrapper
794+
different for MongoDB and PostgreSQL. One way around this is to use a type-erased wrapper
795795
such as the [AnyCodable](https://github.com/Flight-School/AnyCodable) package.
796796
- parameter pipeline: A pipeline of stages to process query.
797797
- parameter options: A set of header options sent to the server. Defaults to an empty set.
@@ -835,7 +835,7 @@ extension Query: Queryable {
835835
- requires: `.useMasterKey` has to be available.
836836
- note: An explain query will have many different underlying types. Since Swift is a strongly
837837
typed language, a developer should specify the type expected to be decoded which will be
838-
different for mongoDB and PostgreSQL. One way around this is to use a type-erased wrapper
838+
different for MongoDB and PostgreSQL. One way around this is to use a type-erased wrapper
839839
such as the [AnyCodable](https://github.com/Flight-School/AnyCodable) package.
840840
- parameter pipeline: A pipeline of stages to process query.
841841
- parameter options: A set of header options sent to the server. Defaults to an empty set.
@@ -941,7 +941,7 @@ extension Query: Queryable {
941941
- requires: `.useMasterKey` has to be available.
942942
- note: An explain query will have many different underlying types. Since Swift is a strongly
943943
typed language, a developer should specify the type expected to be decoded which will be
944-
different for mongoDB and PostgreSQL. One way around this is to use a type-erased wrapper
944+
different for MongoDB and PostgreSQL. One way around this is to use a type-erased wrapper
945945
such as the [AnyCodable](https://github.com/Flight-School/AnyCodable) package.
946946
- parameter key: A field to find distinct values.
947947
- parameter options: A set of header options sent to the server. Defaults to an empty set.
@@ -965,7 +965,7 @@ extension Query: Queryable {
965965
- requires: `.useMasterKey` has to be available.
966966
- note: An explain query will have many different underlying types. Since Swift is a strongly
967967
typed language, a developer should specify the type expected to be decoded which will be
968-
different for mongoDB and PostgreSQL. One way around this is to use a type-erased wrapper
968+
different for MongoDB and PostgreSQL. One way around this is to use a type-erased wrapper
969969
such as the [AnyCodable](https://github.com/Flight-School/AnyCodable) package.
970970
- parameter key: A field to find distinct values.
971971
- parameter options: A set of header options sent to the server. Defaults to an empty set.

Sources/ParseSwift/Types/QueryConstraint.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ public func containedBy <T>(key: String, array: [T]) throws -> QueryConstraint w
373373
- parameter constraint: The key to be constrained. Should be a Date field. The value is a
374374
reference time, e.g. "12 days ago". Currently only comparators supported are: <, <=, >, and >=.
375375
- returns: The same instance of `QueryConstraint` as the receiver.
376-
- warning: This only works with Parse Servers using mongoDB.
376+
- warning: Requires Parse Server 2.6.5+ for MongoDB and Parse Server 5.0.0+ for PostgreSQL.
377377
*/
378378
public func relative(_ constraint: QueryConstraint) -> QueryConstraint {
379379
QueryConstraint(key: constraint.key,

0 commit comments

Comments
 (0)