firebase / firebase-js-sdk

Firebase Javascript SDK
https://firebase.google.com/docs/web/setup
Other
4.82k stars 885 forks source link

Error [FirebaseError]: Function WriteBatch.set() called with invalid data. Unsupported field value: a custom GeoPoint object #5690

Closed ytetsuro closed 2 years ago

ytetsuro commented 2 years ago

[REQUIRED] Describe your environment

[REQUIRED] Describe the problem

Unable to add the GeoPoint class of the SDK for the browser to firestore.

Steps to reproduce:

$ npm i firebase
$ npm i -D @firebase/rules-unit-testing
$ node ./path/to/relevantCode.js

Relevant Code:

const {firestore} = require('firebase');
const firebase = require('@firebase/rules-unit-testing');
const connection = firebase.initializeTestApp({projectId: 'dummy'});
const db = connection.firestore();

const batch = db.batch();
batch.set(db.doc('foo/bar'), {geo: new firestore.GeoPoint(36.2, 41.2)});
batch.commit();
ytetsuro commented 2 years ago

I changed the firebase version to Series 8 and it worked correctly.

$ npm i firebase@^8