Closed rajeshgadepalli closed 5 years ago
It looks as if you did not use geofirestore to add objects to the database, as the entire object must be stored in the d.
field.
If this is the case then this is an issue with how you are putting data into geofirestore, not the library itself (it's behaving as expected).
So did you add the documents with geofirestore?
@MichaelSolati since the requirement to add the Geo Coordinates and search by them was a recent one, I am using Geofirestore to set the coordinates only. I did not want to disturb the existing document structure of UserQRObject for the sake of Geofirestore. Hence this scenario.
Code below on how I am setting the coordinates and how I am setting the rest of the fields
var requestBody=request.body;
if(requestBody===null){
response.status(400).json({error:'Invalid Request Data'});
}
var userId = requestBody.userId;
var qrtype = requestBody.qrType;
var fields = requestBody.fields;
const userQRObject = db.collection('UserQRObject');
var geoFirestore = new GeoFirestore(userQRObject);
geoFirestore.set(userId, { coordinates: new admin.firestore.GeoPoint(17.501303, 78.588136)}).then(() => {
}).then(() => {
db.collection('UserQRObject').doc(userId).update(fields)
.then( doc => {
response.status(200).json('User QR Object Successfully Saved');
}).catch(function(error) {
console.error('Error saving document: ', error);
response.status(400).json('Error saving document: ' + error);
});
}, (error) => {
console.log('Error: ' + error);
response.status(400).json({data:error});
});
Geofirestore is intended to wrap the document, so you shouldn't be trying to store details on the same level as d.
. That's how geofirestore works, it was originally based off of geofire, and that's effectively how that worked. I'd suggest reworking your data to fit the structure geofirestore uses.
(This may change in a later version, however this can not change now as it could/would break functionality for other users and will require a gradual change)
Hi Team,
I am using GeoFirestore. Apart from filtering the data by distance, I also need to filter the results by a field.
This is the init code
And this is the query.
The structure of my collection is
I would like to filter on the profession field. And i am able to do it.
The document object in the results array just contains the coordinates only. I would also like to show the name, phone and profession in the results array.
I am not so much in favor of keeping these fields in the d map object. Is there anyway that I can capture the complete document in the result ?