Code Monkey home page Code Monkey logo

Comments (4)

lsmilek1 avatar lsmilek1 commented on May 18, 2024 1

Do you mean what you posted here, right?

I will switch to server generated Ids as I have basically only one class that got custom objectId to save few cloud code queries. Therefore I believe this situation won't happen anymore as I see that createCommand() and updateCommand() do not throw and saveCommand() has only the .missingObjectId()

// MARK: Saving ParseObjects
static func saveCommand<T>(_ object: T) throws -> API.Command<T, T> where T: ParseObject {
if ParseSwift.configuration.allowCustomObjectId && object.objectId == nil {
throw ParseError(code: .missingObjectId, message: "objectId must not be nil")
}
if object.isSaved {
return updateCommand(object)
}
return createCommand(object)
}
// MARK: Saving ParseObjects - private
private static func createCommand<T>(_ object: T) -> API.Command<T, T> where T: ParseObject {
let mapper = { (data) -> T in
try ParseCoding.jsonDecoder().decode(SaveResponse.self, from: data).apply(to: object)
}
return API.Command<T, T>(method: .POST,
path: object.endpoint(.POST),
body: object,
mapper: mapper)
}
private static func updateCommand<T>(_ object: T) -> API.Command<T, T> where T: ParseObject {
let mapper = { (data) -> T in
try ParseCoding.jsonDecoder().decode(UpdateResponse.self, from: data).apply(to: object)
}
return API.Command<T, T>(method: .PUT,
path: object.endpoint,
body: object,
mapper: mapper)
}

As mixed generated+custom objectId is not supported, do you think that such enhancement would be of any use? I believe we can close this topic, otherwise it would make more sense to support the mixed environment also?

from parse-swift.

cbaker6 avatar cbaker6 commented on May 18, 2024

It seems like you are hitting this particular situation because of what I posted here.

I recommend choosing one of the options I mentioned. The try is throwing correctly:

let commands = try map { try $0.saveCommand() }

If you want to submit a PR and attempt to identify the specific object that throws, I will review it, but attempting to save mixed environment custom objectId's isn't recommended and not supported by the SDK.

from parse-swift.

cbaker6 avatar cbaker6 commented on May 18, 2024

Do you mean what you posted here, right?

Yes

As mixed generated+custom objectId is not supported, do you think that such enhancement would be of any use?

Posting my answer from here for future reference.

I believe we can close this topic

Feel free to close if you don't have any more questions.

from parse-swift.

parse-github-assistant avatar parse-github-assistant commented on May 18, 2024

The label type:feature cannot be used in combination with type:improvement.

from parse-swift.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.