Skip to content

Commit

Permalink
fix(firestore): writebatch
Browse files Browse the repository at this point in the history
fixes: #62
  • Loading branch information
triniwiz committed Mar 12, 2022
1 parent 225042a commit 8b3026f
Show file tree
Hide file tree
Showing 18 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion packages/firebase-admob/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nativescript/firebase-admob",
"version": "1.0.4",
"version": "1.0.5",
"description": "NativeScript Firebase - Admob",
"main": "index",
"typings": "index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/firebase-analytics/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nativescript/firebase-analytics",
"version": "1.0.4",
"version": "1.0.5",
"description": "NativeScript Firebase - Analytics",
"main": "index",
"typings": "index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/firebase-app-check/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nativescript/firebase-app-check",
"version": "1.0.4",
"version": "1.0.5",
"description": "NativeScript Firebase - App Check",
"main": "index",
"typings": "index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/firebase-auth/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nativescript/firebase-auth",
"version": "1.0.4",
"version": "1.0.5",
"description": "NativeScript Firebase - Auth",
"main": "index",
"typings": "index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/firebase-core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nativescript/firebase-core",
"version": "1.0.4",
"version": "1.0.5",
"description": "NativeScript Firebase - Core",
"main": "index",
"typings": "index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/firebase-crashlytics/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nativescript/firebase-crashlytics",
"version": "1.0.4",
"version": "1.0.5",
"description": "NativeScript Firebase - Crashlytics",
"main": "index",
"typings": "index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/firebase-database/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nativescript/firebase-database",
"version": "1.0.4",
"version": "1.0.5",
"description": "NativeScript Firebase - Database",
"main": "index",
"typings": "index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/firebase-dynamic-links/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nativescript/firebase-dynamic-links",
"version": "1.0.4",
"version": "1.0.5",
"description": "NativeScript Firebase - Dynamic Links",
"main": "index",
"typings": "index.d.ts",
Expand Down
10 changes: 5 additions & 5 deletions packages/firebase-firestore/index.android.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ICollectionReference, IDocumentReference, IFieldPath, IFieldValue, IGeo

export { SetOptions, DocumentData, GetOptions, WhereFilterOp };

import { deserialize, firebase, FirebaseApp, FirebaseError, serialize } from '@nativescript/firebase-core';
import { firebase, FirebaseApp, FirebaseError, serialize } from '@nativescript/firebase-core';

let defaultFirestore: Firestore;

Expand Down Expand Up @@ -1371,23 +1371,23 @@ export class WriteBatch implements IWriteBatch {
if (options) {
if (typeof options?.merge === 'boolean') {
const opts = com.google.firebase.firestore.SetOptions.merge();
return WriteBatch.fromNative(this.native.set(serialize(data), documentRef.native, opts));
return WriteBatch.fromNative(this.native.set(serializeItems(data), documentRef.native, opts));
}

if (options.mergeFields) {
if (Array.isArray(options.mergeFields)) {
if (typeof options.mergeFields[0] === 'string') {
return WriteBatch.fromNative(this.native.set(serialize(data), documentRef.native, com.google.firebase.firestore.SetOptions.mergeFields(options.mergeFields as any)));
return WriteBatch.fromNative(this.native.set(serializeItems(data), documentRef.native, com.google.firebase.firestore.SetOptions.mergeFields(options.mergeFields as any)));
}

const list = java.util.Arrays.asList(options.mergeFields.map((field) => field.native));
return WriteBatch.fromNative(this.native.set(serialize(data), documentRef.native, com.google.firebase.firestore.SetOptions.mergeFields(list)));
return WriteBatch.fromNative(this.native.set(serializeItems(data), documentRef.native, com.google.firebase.firestore.SetOptions.mergeFields(list)));
}
}

return null;
} else {
return WriteBatch.fromNative(this.native.set(serialize(data), documentRef.native));
return WriteBatch.fromNative(this.native.set(serializeItems(data), documentRef.native));
}
}

Expand Down
10 changes: 5 additions & 5 deletions packages/firebase-firestore/index.ios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ICollectionReference, IDocumentReference, IFieldPath, IFieldValue, IGeo

const main_queue = dispatch_get_current_queue();

import { deserialize, firebase, FirebaseApp, FirebaseError, serialize } from '@nativescript/firebase-core';
import { firebase, FirebaseApp, FirebaseError, serialize } from '@nativescript/firebase-core';

let defaultFirestore: Firestore;

Expand Down Expand Up @@ -1190,18 +1190,18 @@ export class WriteBatch implements IWriteBatch {
set(documentRef: DocumentReference, data: DocumentData, options?: SetOptions): WriteBatch {
if (options) {
if (typeof options?.merge === 'boolean') {
return WriteBatch.fromNative(this.native.setDataForDocumentMerge(serialize(data), documentRef.native, options.merge));
return WriteBatch.fromNative(this.native.setDataForDocumentMerge(serializeItems(data), documentRef.native, options.merge));
}

if (options.mergeFields) {
if (Array.isArray(options.mergeFields)) {
if (typeof options.mergeFields[0] === 'string') {
return WriteBatch.fromNative(this.native.setDataForDocumentMergeFields(serialize(data), documentRef.native, options.mergeFields));
return WriteBatch.fromNative(this.native.setDataForDocumentMergeFields(serializeItems(data), documentRef.native, options.mergeFields));
}

return WriteBatch.fromNative(
this.native.setDataForDocumentMergeFields(
serialize(data),
serializeItems(data),
documentRef.native,
options.mergeFields.map((field) => field.native)
)
Expand All @@ -1211,7 +1211,7 @@ export class WriteBatch implements IWriteBatch {

return null;
} else {
return WriteBatch.fromNative(this.native.setDataForDocument(serialize(data), documentRef.native));
return WriteBatch.fromNative(this.native.setDataForDocument(serializeItems(data), documentRef.native));
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/firebase-firestore/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nativescript/firebase-firestore",
"version": "1.0.4",
"version": "1.0.5",
"description": "NativeScript Firebase - Firestore",
"main": "index",
"typings": "index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/firebase-functions/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nativescript/firebase-functions",
"version": "1.0.4",
"version": "1.0.5",
"description": "NativeScript Firebase - Functions",
"main": "index",
"typings": "index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/firebase-in-app-messaging/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nativescript/firebase-in-app-messaging",
"version": "1.0.4",
"version": "1.0.5",
"description": "NativeScript Firebase - In App Messaging",
"main": "index",
"typings": "index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/firebase-installations/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nativescript/firebase-installations",
"version": "1.0.4",
"version": "1.0.5",
"description": "NativeScript Firebase - Installations",
"main": "index",
"typings": "index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/firebase-messaging/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nativescript/firebase-messaging",
"version": "1.0.4",
"version": "1.0.5",
"description": "NativeScript Firebase - Messaging",
"main": "index",
"typings": "index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/firebase-performance/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nativescript/firebase-performance",
"version": "1.0.4",
"version": "1.0.5",
"description": "NativeScript Firebase - Performancee",
"main": "index",
"typings": "index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/firebase-remote-config/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nativescript/firebase-remote-config",
"version": "1.0.4",
"version": "1.0.5",
"description": "NativeScript Firebase - Remote Config",
"main": "index",
"typings": "index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/firebase-storage/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nativescript/firebase-storage",
"version": "1.0.4",
"version": "1.0.5",
"description": "NativeScript Firebase - Storage",
"main": "index",
"typings": "index.d.ts",
Expand Down

0 comments on commit 8b3026f

Please sign in to comment.