Skip to content

feat: add create(), replace(), and update() to ParseObjects #299

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

Merged
merged 5 commits into from
Dec 12, 2021
Merged

feat: add create(), replace(), and update() to ParseObjects #299

merged 5 commits into from
Dec 12, 2021

Conversation

cbaker6
Copy link
Contributor

@cbaker6 cbaker6 commented Dec 11, 2021

New Pull Request Checklist

Issue Description

Currently developers have to use save() or saveAll() to POST/PUT objects on a Parse Server. Depending on the configuration, save and saveAll determines what command to send to the server based on the objectId, createdAt, or a combination of both.

There should be methods to allow the developer to either POST or PUT where the developer can handle any errors that may come up. This would make it easier for the developer to use a mixed environment of generating objectId’s on the client and server for different objects.

Related issue: #n/a

Approach

Add create() (POST), replace() (PUT), and update() (PATCH), createAll(), replaceAll(), and updateAll() to all ParseObject's. Follows method discussed in #220 (comment). update() and updateAll() are marked as internal methods until the server supports PATCH.

Note: Only asynchronous methods using a completion handler, Combine, and async/await are added. No synchronous methods will be added as the developer should be using asynchronous for network calls.

TODOs before merging

  • Refactored ParseObject, ParseUser, and ParseInstallation to reuse more code when using completion callbacks
  • Make .POST compatible with current version of .POST on server as well as spec compliant .POST
  • Make SDK ready for .PATCH and as http spec compliant as possible while still working with current versions of the Parse Server. All PATCH calls are marked as “internal” and are not usable by developers since PATCH isn't supported on the server yet. This is a continuation on Future proof SDK by always sending clientVersion header #146
  • Add tests
  • Add entry to changelog
  • Add changes to documentation (guides, repository pages, in-code descriptions)

@parse-github-assistant
Copy link

parse-github-assistant bot commented Dec 11, 2021

Thanks for opening this pull request!

  • 🎉 We are excited about your hands-on contribution!

@codecov
Copy link

codecov bot commented Dec 11, 2021

Codecov Report

Merging #299 (b14e3a6) into main (aa22991) will increase coverage by 0.70%.
The diff coverage is 93.78%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #299      +/-   ##
==========================================
+ Coverage   82.91%   83.62%   +0.70%     
==========================================
  Files         105      105              
  Lines       10595    11187     +592     
==========================================
+ Hits         8785     9355     +570     
- Misses       1810     1832      +22     
Impacted Files Coverage Δ
...cation/3rd Party/ParseApple/ParseApple+async.swift 100.00% <ø> (ø)
.../3rd Party/ParseFacebook/ParseFacebook+async.swift 100.00% <ø> (ø)
...tication/3rd Party/ParseLDAP/ParseLDAP+async.swift 100.00% <ø> (ø)
...on/3rd Party/ParseTwitter/ParseTwitter+async.swift 100.00% <ø> (ø)
...Authentication/Internal/ParseAnonymous+async.swift 100.00% <ø> (ø)
...tication/Protocols/ParseAuthentication+async.swift 85.71% <ø> (ø)
...Authentication/Protocols/ParseAuthentication.swift 72.44% <ø> (ø)
...es/ParseSwift/LiveQuery/ParseLiveQuery+async.swift 72.72% <ø> (ø)
...rces/ParseSwift/Protocols/ParseObjectMutable.swift 100.00% <ø> (ø)
...ources/ParseSwift/Types/ParseAnalytics+async.swift 100.00% <ø> (ø)
... and 26 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update aa22991...b14e3a6. Read the comment docs.

@cbaker6
Copy link
Contributor Author

cbaker6 commented Dec 11, 2021

@lsmilek1 this should make the issues brought up in #220 about custom objectId easier to use as you don't need isIgnoreCustomObjectIdConfig. You will need to know if you are trying to create or update an object and should handle errors if thrown.

@cbaker6 cbaker6 changed the title feat: add create() and update() methods to ParseObjects feat: add create(), replace, and update() to ParseObjects Dec 11, 2021
@cbaker6 cbaker6 changed the title feat: add create(), replace, and update() to ParseObjects feat: add create(), replace(), and update() to ParseObjects Dec 11, 2021
@cbaker6 cbaker6 merged commit ebaaf12 into parse-community:main Dec 12, 2021
@cbaker6 cbaker6 deleted the createUpdate branch December 12, 2021 00:29
@lsmilek1
Copy link
Contributor

@cbaker6 , I still need to have requiringCustomObjectIds: true in ParseSwift.initialize else the server returns .Not Found error when I use .create() with objectId set for not yet existing object:

profile from device could not be uploaded, error saving: ParseError code=-1 error=Not Found, profile: Profile ({"ACL":{"*":{"read":true},"VZjyzUPgRk":{"read":true,"write":true}},"ag":0,"bf":258787,"co":1,"d":false,"da":2,"ed":5,"gn":0,"idr":3,"ih":0,"ik":4,"ism":3,"isp":3,"ll":[],"nl":[],"o":1,"objectId":"VZjyzUPgRk","on":false,"ph":[null,null],"pk":{"__type":"Bytes","base64":"XGBGirHaNNfW8LQPG7PH7pa8jqoT2xckPpc+ets8C38="},"pl":0,"po":0,"pt":[null,null],"rl":0,"s":2,"sh":true,"sl":[],"sq":[],"th":0,"tn":1,"tr":1,"tv":0,"tz":"Europe/Berlin"})

But in that case I would still need to use ignoringCustomObjectIdConfig on all .save()

Parse server 6.2.0, Parse-Swift 4.14.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants