Skip to content

[FIX] Firestore.FieldValue(arrayUnion||arrayRemove||increment) - iOS - #48

Open
spoxies wants to merge 6 commits into
ReallySmallSoftware:masterfrom
spoxies:fix-fieldvalue-array-functions-ios
Open

[FIX] Firestore.FieldValue(arrayUnion||arrayRemove||increment) - iOS#48
spoxies wants to merge 6 commits into
ReallySmallSoftware:masterfrom
spoxies:fix-fieldvalue-array-functions-ios

Conversation

@spoxies

@spoxies spoxies commented May 18, 2023

Copy link
Copy Markdown

Fixes
Firestore.Firestore.FieldValue.arrayUnion()
Firestore.Firestore.FieldValue.arrayRemove()
Firestore.Firestore.FieldValue.increment(1)

Example use case:

var firebaseOptions = {
    "datePrefix": '__DATE:',
    "fieldValueDelete": "__DELETE",
    "fieldValueServerTimestamp": "__SERVERTIMESTAMP",
    "persist": true,
};

Firestore.initialise(firebaseOptions).then(function (db) {
    // Add a second document with a generated ID.
    return db.get().collection("users").doc("someUserId").update({
        someField : Firestore.Firestore.FieldValue.arrayUnion('carrot'),
        someCount: Firestore.Firestore.FieldValue.increment(4)
    }).catch(function (error) {
        console.error("Error adding document: ", error);
    });
});

Proposed Changes

  • JSONArrayToArray (re)introduce/complete logic

@spoxies

spoxies commented May 18, 2023

Copy link
Copy Markdown
Author

Colon was not removed by unwrap method in @implementation FirestorePluginJSONHelper (iOS) eg:
"__INCREMENT:4" returned ":4" instead of "4"

Added +1 to return [stringValue substringFromIndex:prefix.length+1];.

Seems this was all ready implemented as such on Android FieldValueHelper.java

@spoxies spoxies changed the title [FIX] Firestore.FieldValue(arrayUnion||arrayRemove) - iOS [FIX] Firestore.FieldValue(arrayUnion||arrayRemove||increment) - iOS May 18, 2023
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.

1 participant