Comments (11)
Thanks for reporting this, I will try to push a fix for this in the next release.
from nodejs-firestore.
@rodrigoreal How are you saving the GeoPoint? As a top-level entity or within an object? We currently only support GeoPoints within a different object.
from nodejs-firestore.
@schmidt-sebastian
I'm saving it as an object on my seller entity.
const seller: SellersInterface = {
name: body.name,
location: new firestore.GeoPoint(lat, lng)
};
admin.firestore().collection('sellers').add(seller);
export interface SellersInterface {
id?: string;
name: string;
location: firestore.GeoPoint;
}
I'm doing something wrong?
from nodejs-firestore.
The Firestore SDK can only recognize types that are part of its own namespace. Since you are using Firestore through the Admin SDK, you need to save GeoPoints as follows:
admin.firestore().collection('sellers').add({
location:new admin.firestore.GeoPoint(1.0, 1.0)
});
I'm going to close this issue for now. If the above doesn't help, please feel free to re-open.
from nodejs-firestore.
Hi,
not able to save geo point. I am doing the same as you mentioned above but it does not help me.
Please have a look on my code.
const admin = require("firebase-admin");
const serviceAccount = require(process.env.FBASE_AUTH_FILE);
admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
databaseURL: process.env.dbURL
});
let d = new Date();
let data = {
name: 'Amit',
location: new admin.firestore.GeoPoint(28.52038,77.28073),
created_at: d.getTime()
}
setDoc = db.collection('users').doc().set(data);
if (setDoc) {
console.log('User added');
}
// Error which I am receiving is as follows.
Error: Cannot encode type ([object Object]) to a Firestore Value
from nodejs-firestore.
Where are you getting Firestore from ('db')? If I add the following, your code works:
const Firestore = admin.firestore;
const db = Firestore();
At the moment, you can't mix and match the instances returned from GCloud and the Firebase Admin SDK.
from nodejs-firestore.
@schmidt-sebastian
Thanks.. It work.
Yes, i was using the GCloud instance to save data in collection.
I am facing one more issue with firestore.
Can I fetch data from multiple collections using join? As we can do same in MySQL and MongoDB as well.
Your response will be much appreciable.
from nodejs-firestore.
We currently don't expose a join operation. If you know the keys of your data, you can use getAll() on the main Firestore class.
from nodejs-firestore.
When I use a google cloud function written in typescript to retrieve a document containing Geopoint, I am hitting the same issue with the response containing _latitude and _longitude for geopoint.
const Firestore = admin.firestore;
const db = Firestore();
const snap = await db
.collection("addresses")
.doc(docId)
.get();
const snapdata = snap.data();
console.log(snapdata);
from nodejs-firestore.
@surya-fleetrun-in, when I run this code, I see this logged:
{
point: GeoPoint {
_latitude: 44.04818119788449,
_longitude: -109.7278059330043
}
}
It looks like console.log(snapdata)
is logging the private properties of the GeoPoint object.
However, the returned point
object is an instance of the GeoPoint
class, so you should be able to use the latitude
and longitude
getters.
console.log(snapdata['point'].latitude);
console.log(snapdata['point'].longitude);
I tested using [email protected].
from nodejs-firestore.
Thanks @MarkDuckworth the postman response is also showing the private properties, which confused us a little, but the getter seems to work.
from nodejs-firestore.
Related Issues (20)
- count queries: "after each" hook for "counts with startAt, endAt and offset" failed
- Investigate whether this workaround is still needed re: dropping resource header
- Aggregation queries: "after each" hook for "can get duplicate aggregations using aggregate api" failed HOT 1
- count queries using aggregate api: "after each" hook for "counts multiple documents with filter" failed
- [Documentation] Disambiguate DocumentRef.create documentation HOT 3
- FR: Firestore Timestamp should have a comparator method HOT 1
- count queries using aggregate api Run within Transaction: counts with startAt, endAt and offset with DocumentSnapshot cursor failed HOT 1
- [docs] FirestoreAdminClient.exportDocuments() no longer in docs HOT 2
- ClientPool.clientFactory crashing in serverless environments HOT 3
- Update google-gax dependency to 4.x.x for @google-cloud/firestore 6.x.x HOT 2
- BulkWriter class recursiveDelete(): on leaf document failed HOT 2
- Expose databaseId and projectId on Firestore class HOT 1
- Unstable write/reading time after multiple executions HOT 9
- How to avoid Auth error using `preferRest: true` HOT 4
- Aggregation queries: "after each" hook for "aggregate query supports collection groups" failed HOT 1
- Need guidance on use of preferRest; FIRESTORE_PREFER_REST is now being set to true by default in firebase functions causing preferRest to be default rather than opt-in HOT 10
- Aggregation queries: "after each" hook for "can run sum query" failed HOT 1
- Aggregation queries: "after each" hook for "performs sum over a result set of zero documents" failed
- Firestore query "and" inside other "and" function not working HOT 1
- Warning: a recent release failed
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nodejs-firestore.