Skip to content

Commit baa8f7a

Browse files
authored
refactor: switch to primaryKey (#7)
* Update Parse and Leaf * Switch to primaryKey * bump ParseSwift
1 parent f4f18c6 commit baa8f7a

File tree

8 files changed

+38
-27
lines changed

8 files changed

+38
-27
lines changed

Package.resolved

+18-9
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333
"repositoryURL": "https://github.com/vapor/leaf.git",
3434
"state": {
3535
"branch": null,
36-
"revision": "04f262edbee143cdfefc5b26cef704913712e16c",
37-
"version": "4.2.1"
36+
"revision": "bf1c27928c3f7f93fcdca570d7514727fa23e14e",
37+
"version": "4.2.2"
3838
}
3939
},
4040
{
@@ -57,11 +57,11 @@
5757
},
5858
{
5959
"package": "ParseSwift",
60-
"repositoryURL": "https://github.com/parse-community/Parse-Swift.git",
60+
"repositoryURL": "https://github.com/netreconlab/Parse-Swift.git",
6161
"state": {
6262
"branch": null,
63-
"revision": "40a7b42b20c22253d53b09dc49c37fbb7973fdfe",
64-
"version": "4.14.1"
63+
"revision": "8c58ad28038d2d2894257ceba98ed1f3d2b11e0c",
64+
"version": "4.15.1"
6565
}
6666
},
6767
{
@@ -82,6 +82,15 @@
8282
"version": "1.0.0"
8383
}
8484
},
85+
{
86+
"package": "swift-atomics",
87+
"repositoryURL": "https://github.com/apple/swift-atomics.git",
88+
"state": {
89+
"branch": null,
90+
"revision": "919eb1d83e02121cdb434c7bfc1f0c66ef17febe",
91+
"version": "1.0.2"
92+
}
93+
},
8594
{
8695
"package": "swift-backtrace",
8796
"repositoryURL": "https://github.com/swift-server/swift-backtrace.git",
@@ -132,8 +141,8 @@
132141
"repositoryURL": "https://github.com/apple/swift-nio.git",
133142
"state": {
134143
"branch": null,
135-
"revision": "124119f0bb12384cef35aa041d7c3a686108722d",
136-
"version": "2.40.0"
144+
"revision": "bc4c55b9f9584f09eb971d67d956e28d08caa9d0",
145+
"version": "2.43.1"
137146
}
138147
},
139148
{
@@ -186,8 +195,8 @@
186195
"repositoryURL": "https://github.com/vapor/vapor.git",
187196
"state": {
188197
"branch": null,
189-
"revision": "dda0de537e7906414dccd551e77095be1e34e3da",
190-
"version": "4.65.2"
198+
"revision": "43fc875b4faa27d23d9561e8c069357d3dec27f4",
199+
"version": "4.66.1"
191200
}
192201
},
193202
{

Package.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ let package = Package(
1111
],
1212
dependencies: [
1313
// 💧 A server-side Swift web framework.
14-
.package(url: "https://github.com/vapor/vapor.git", .upToNextMajor(from: "4.65.2")),
15-
.package(url: "https://github.com/vapor/leaf.git", .upToNextMajor(from: "4.2.1")),
16-
.package(url: "https://github.com/parse-community/Parse-Swift.git",
17-
.upToNextMajor(from: "4.14.1")),
14+
.package(url: "https://github.com/vapor/vapor.git", .upToNextMajor(from: "4.66.1")),
15+
.package(url: "https://github.com/vapor/leaf.git", .upToNextMajor(from: "4.2.2")),
16+
.package(url: "https://github.com/netreconlab/Parse-Swift.git",
17+
.upToNextMajor(from: "4.15.1")),
1818
],
1919
targets: [
2020
.target(

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ guard let parseServerUrl = URL(string: "http://localhost:1337/1") else {
4141
// Initialize the Parse-Swift SDK
4242
ParseSwift.initialize(applicationId: "applicationId", // Required: Change to your applicationId.
4343
clientKey: "clientKey", // Required: Change to your clientKey.
44-
masterKey: "masterKey", // Required: Change to your masterKey.
44+
primaryKey: "primaryKey", // Required: Change to your primaryKey.
4545
serverURL: parseServerUrl,
4646
usingPostForQuery: true) { _, completionHandler in
4747
completionHandler(.performDefaultHandling, nil)
@@ -139,9 +139,9 @@ app.post("bar",
139139
return ParseHookResponse(error: .init(code: .missingObjectId,
140140
message: "Object not sent in request."))
141141
}
142-
// To query using the masterKey pass the `useMasterKey option
142+
// To query using the primaryKey pass the `usePrimaryKey` option
143143
// to ther query.
144-
let scores = try await GameScore.query.findAll(options: [.useMasterKey])
144+
let scores = try await GameScore.query.findAll(options: [.usePrimaryKey])
145145
req.logger.info("All scores: \(scores)")
146146
return ParseHookResponse(success: object)
147147
}

Sources/ParseServerSwift/Documentation.docc/Cloud Code.tutorial

+4-4
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@
5757
return ParseHookResponse(error: .init(code: .missingObjectId,
5858
message: "Object not sent in request."))
5959
}
60-
// To query using the masterKey pass the `useMasterKey option
60+
// To query using the primaryKey pass the `usePrimaryKey` option
6161
// to ther query.
62-
let scores = try await GameScore.query.findAll(options: [.useMasterKey])
62+
let scores = try await GameScore.query.findAll(options: [.usePrimaryKey])
6363
req.logger.info("All scores: \(scores)")
6464
return ParseHookResponse(success: object)
6565
}
@@ -179,9 +179,9 @@
179179
return ParseHookResponse(error: .init(code: .missingObjectId,
180180
message: "Object not sent in request."))
181181
}
182-
// To query using the masterKey pass the `useMasterKey option
182+
// To query using the primaryKey pass the `usePrimaryKey` option
183183
// to ther query.
184-
let scores = try await GameScore.query.findAll(options: [.useMasterKey])
184+
let scores = try await GameScore.query.findAll(options: [.usePrimaryKey])
185185
req.logger.info("All scores: \(scores)")
186186
return ParseHookResponse(success: object)
187187
}

Sources/ParseServerSwift/Documentation.docc/Configuring Parse Server Swift.tutorial

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
// Initialize the Parse-Swift SDK
3939
ParseSwift.initialize(applicationId: "applicationId", // Required: Change to your applicationId.
4040
clientKey: "clientKey", // Required: Change to your clientKey.
41-
masterKey: "masterKey", // Required: Change to your masterKey.
41+
primaryKey: "primaryKey", // Required: Change to your primaryKey.
4242
serverURL: parseServerUrl,
4343
usingPostForQuery: true) { _, completionHandler in
4444
completionHandler(.performDefaultHandling, nil)

Sources/ParseServerSwift/Models/User.swift

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//
22
// User.swift
3-
//
3+
//
44
//
55
// Created by Corey E. Baker on 6/20/22.
66
//
@@ -9,8 +9,8 @@ import Foundation
99
import ParseSwift
1010

1111
/**
12-
An example `ParseUser`. You will want to replace this
13-
with your version of `ParseUser`.
12+
An example `ParseUser`. You will want to add custom
13+
properties to reflect the `ParseUser` on your Parse Server.
1414
*/
1515
struct User: ParseCloudUser {
1616

@@ -25,4 +25,6 @@ struct User: ParseCloudUser {
2525
var ACL: ParseACL?
2626
var originalData: Data?
2727
var sessionToken: String?
28+
// var _failed_login_count: Int?
29+
// var _account_lockout_expires_at: Date?
2830
}

Sources/ParseServerSwift/configure.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public func configure(_ app: Application) throws {
3535
// Initialize the Parse-Swift SDK
3636
ParseSwift.initialize(applicationId: "applicationId", // Required: Change to your applicationId.
3737
clientKey: "clientKey", // Required: Change to your clientKey.
38-
masterKey: "masterKey", // Required: Change to your masterKey.
38+
primaryKey: "primaryKey", // Required: Change to your primaryKey.
3939
serverURL: parseServerUrl,
4040
usingPostForQuery: true) { _, completionHandler in
4141
completionHandler(.performDefaultHandling, nil)

Sources/ParseServerSwift/routes.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ func routes(_ app: Application) throws {
5454
return ParseHookResponse(error: .init(code: .missingObjectId,
5555
message: "Object not sent in request."))
5656
}
57-
// To query using the masterKey pass the `useMasterKey option
57+
// To query using the primaryKey pass the `usePrimaryKey` option
5858
// to ther query.
59-
let scores = try await GameScore.query.findAll(options: [.useMasterKey])
59+
let scores = try await GameScore.query.findAll(options: [.usePrimaryKey])
6060
req.logger.info("All scores: \(scores)")
6161
return ParseHookResponse(success: object)
6262
}

0 commit comments

Comments
 (0)