-
-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(firestore): support batched writes (#643)
* feat(firestore): support batched writes * style: format * docs * fix * wip
- Loading branch information
Showing
16 changed files
with
334 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@capacitor-firebase/firestore': minor | ||
--- | ||
|
||
feat: support batched writes |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
...apawesome/capacitorjs/plugins/firebase/firestore/classes/options/WriteBatchOperation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package io.capawesome.capacitorjs.plugins.firebase.firestore.classes.options; | ||
|
||
import androidx.annotation.NonNull; | ||
import com.getcapacitor.JSObject; | ||
import io.capawesome.capacitorjs.plugins.firebase.firestore.FirebaseFirestoreHelper; | ||
import java.util.Map; | ||
import org.json.JSONException; | ||
|
||
public class WriteBatchOperation { | ||
|
||
private String type; | ||
private String reference; | ||
private Map<String, Object> data; | ||
|
||
public WriteBatchOperation(@NonNull JSObject operation) throws JSONException { | ||
this.type = operation.getString("type"); | ||
this.reference = operation.getString("reference"); | ||
this.data = FirebaseFirestoreHelper.createHashMapFromJSONObject(operation.getJSObject("data")); | ||
} | ||
|
||
public String getType() { | ||
return type; | ||
} | ||
|
||
public String getReference() { | ||
return reference; | ||
} | ||
|
||
public Map<String, Object> getData() { | ||
return data; | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
.../capawesome/capacitorjs/plugins/firebase/firestore/classes/options/WriteBatchOptions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package io.capawesome.capacitorjs.plugins.firebase.firestore.classes.options; | ||
|
||
import androidx.annotation.NonNull; | ||
import androidx.annotation.Nullable; | ||
import com.getcapacitor.JSArray; | ||
import com.getcapacitor.JSObject; | ||
import org.json.JSONException; | ||
|
||
public class WriteBatchOptions { | ||
|
||
private WriteBatchOperation[] operations; | ||
|
||
public WriteBatchOptions(@Nullable JSArray operations) throws JSONException { | ||
this.operations = createWriteBatchOperationArrayFromJSArray(operations); | ||
} | ||
|
||
@NonNull | ||
private static WriteBatchOperation[] createWriteBatchOperationArrayFromJSArray(@Nullable JSArray data) throws JSONException { | ||
if (data == null) { | ||
return new WriteBatchOperation[0]; | ||
} else { | ||
WriteBatchOperation[] operations = new WriteBatchOperation[data.length()]; | ||
for (int i = 0; i < data.length(); i++) { | ||
JSObject operation = JSObject.fromJSONObject(data.getJSONObject(i)); | ||
operations[i] = new WriteBatchOperation(operation); | ||
} | ||
return operations; | ||
} | ||
} | ||
|
||
@NonNull | ||
public WriteBatchOperation[] getOperations() { | ||
return operations; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.