|
3 | 3 | [](https://swiftpackageindex.com/netreconlab/parse-server-swift/documentation)
|
4 | 4 | [](https://netreconlab.github.io/parse-server-swift/release/tutorials/parseserverswift/)
|
5 | 5 | [](https://github.com/netreconlab/parse-server-swift/actions?query=workflow%3Aci+branch%3Amain)
|
| 6 | +[](https://github.com/netreconlab/parse-server-swift/actions/workflows/release.yml) |
6 | 7 | [](https://codecov.io/gh/netreconlab/parse-server-swift)
|
7 | 8 | [](https://swiftpackageindex.com/netreconlab/parse-server-swift)
|
8 | 9 | [](https://swiftpackageindex.com/netreconlab/parse-server-swift)
|
@@ -80,7 +81,36 @@ To start your server type, `swift run` in the terminal of the project root direc
|
80 | 81 |
|
81 | 82 | ## Writing Cloud Code
|
82 | 83 | ### Creating `ParseObject`'s
|
83 |
| -It is recommended to add all of your `ParseObject`'s in a folder called `Models` similar to [ParseServerSwift/Sources/ParseServerSwift/Models](https://github.com/netreconlab/ParseServerSwift/blob/main/Sources/ParseServerSwift/Models). For example, the `GameScore` model is below: |
| 84 | +It is recommended to add all of your `ParseObject`'s in a folder called `Models` similar to [ParseServerSwift/Sources/ParseServerSwift/Models](https://github.com/netreconlab/ParseServerSwift/blob/main/Sources/ParseServerSwift/Models). |
| 85 | + |
| 86 | +#### The `ParseUser` Model |
| 87 | +Be mindful that the `ParseUser` in `ParseServerSwift` should conform to [ParseCloudUser](https://swiftpackageindex.com/netreconlab/parse-swift/4.16.2/documentation/parseswift/parseclouduser). In addition, make sure to add all of the additional properties you have in your `_User` class to the `User` model. An example `User` model is below: |
| 88 | + |
| 89 | +```swift |
| 90 | +/** |
| 91 | + An example `ParseUser`. You will want to add custom |
| 92 | + properties to reflect the `ParseUser` on your Parse Server. |
| 93 | + */ |
| 94 | +struct User: ParseCloudUser { |
| 95 | + |
| 96 | + var authData: [String: [String: String]?]? |
| 97 | + var username: String? |
| 98 | + var email: String? |
| 99 | + var emailVerified: Bool? |
| 100 | + var password: String? |
| 101 | + var objectId: String? |
| 102 | + var createdAt: Date? |
| 103 | + var updatedAt: Date? |
| 104 | + var ACL: ParseACL? |
| 105 | + var originalData: Data? |
| 106 | + var sessionToken: String? |
| 107 | + var _failed_login_count: Int? |
| 108 | + var _account_lockout_expires_at: Date? |
| 109 | +} |
| 110 | +``` |
| 111 | + |
| 112 | +#### An example `ParseObject` |
| 113 | +The `GameScore` model is below: |
84 | 114 |
|
85 | 115 | ```swift
|
86 | 116 | import Foundation
|
@@ -113,9 +143,6 @@ struct GameScore: ParseObject {
|
113 | 143 | }
|
114 | 144 | ```
|
115 | 145 |
|
116 |
| -#### The `ParseUser` Model |
117 |
| -Be sure to add all of the additional properties you have in your `_User` class to the `User` model. An example `User` model can be found at [ParseServerSwift/Sources/ParseServerSwift/Models/User.swift](https://github.com/netreconlab/ParseServerSwift/blob/main/Sources/ParseServerSwift/Models/User.swift) |
118 |
| - |
119 | 146 | ### Creating New Cloud Code Routes
|
120 | 147 | Adding routes for `ParseHooks` are as simple as adding [routes in Vapor](https://docs.vapor.codes/basics/routing/). `ParseServerSwift` provides some additional methods to routes to easily create and register [Hook Functions](https://parseplatform.org/Parse-Swift/release/documentation/parseswift/parsehookfunctionable) and [Hook Triggers](https://parseplatform.org/Parse-Swift/release/documentation/parseswift/parsehooktriggerable/). All routes should be added to the `routes.swift` file in your project. Example `ParseServerSwift` routes can be found in [ParseServerSwift/Sources/ParseServerSwift/routes.swift](https://github.com/netreconlab/ParseServerSwift/blob/main/Sources/ParseServerSwift/routes.swift).
|
121 | 148 |
|
|
0 commit comments