BigQuery export selected field from Firebase firestore history data to excel - google-cloud-firestore

I am writing big query code to export firestore history data to excel. I want to get all the data of a particular machineId which is present in my firestore. this is the structure of my firestore
and this is the code:- https://codesandbox.io/s/young-rain-6s0hzj
Error:- Unrecognized name: data
but this is giving some error can anyone suggest me some documentation.

Related

Get collection inside document in Firestore with Firebase v9?

I have a Firestore collection inside of a document and I'd like to get the contents of provider:
I thought this would be easy enough but I'm stuck even after following the documentation on the official Firebase website.
I'm using Python 3 and Firebase Firestore v9.
productsCollectionRef = self.client.collection("products")
for productDocRef in productsCollectionRef.stream():
providerCollections = productDocRef.collections() # ERROR
for providerCollection in providerCollections: # There's only one sub-collection
for providerDocRef in providerCollection.stream():
print(providerDocRef)
The error I get at productDocRef.collections() is AttributeError: 'DocumentSnapshot' object has no attribute 'collections'.
What I've tried
The official Firebase doc sample: https://cloud.google.com/firestore/docs/samples/firestore-data-get-sub-collections#code-sample
Similar usage: Firestore: List subcollections of a document using python
DocumentSnapshot object docs: https://cloud.google.com/python/docs/reference/firestore/latest/google.cloud.firestore_v1.base_document.DocumentSnapshot?skip_cache=false#methods

Get the latest data from Firestore database into Flutter App

Right now my app can send the user location to Firestore database continuously. but I can't find a way to access only the last location data sent to Firestore so that I can retrieve it and plot it into the map.
i am using below method to send data into firestore.
_addGeoPoint(LatLng myloc) {
GeoFirePoint myLocation =
geo.point(latitude: myloc.latitude, longitude: myloc.longitude);
firestore
.collection('locations')
.add({'busName': 'WP9885','routeNo':'155','position': myLocation.data});
}
Firestore doesn't have a concept of "last" or "most recent" data. You should store a server timestamp field in your document if you want to add a sense of time to the documents in your collection.
If you have a timestamp field in each document, then you can query for the most recently added document using code similar to this:
firestore
.collection("locations")
.orderBy("location", "desc")
.limit(1)

Firestore filter data by month

I'm trying to filter a data collection by month. But it's giving me an error TypeError: _this._firestore.collection('Employee').orderByChild is not a function. Below is my code and database structure
const month = 5
firestore.collection('Employee').orderByChild("month").equalTo(month).once('value',snapshot=>{
snapshot.forEach((childSnapshot)=>{
var users = childSnapshot.key;
})
})
What you're showing is not valid Firestore syntax at all. It looks like you're mixing up Firestore queries with Realtime Database queries. There is no orderByChild on a Firestore query, but there is on Realtime Database queries. On top of that, you have no field called "month" in the document you're showing here, so it's not clear at all what you're trying to do with this query.
If you're using Firestore, I strongly suggest you familiarize yourself with Firestore queries using the documentation. Ignore any documentation about Realtime Database.

How to serarch from JSON data with MongoDB

I am new in MongoDB. I am using MongoDB 3.6.3. I have one fields in the document with huge josn data and I don't know all key names present inside JSON data.
Now I want to search documents by the value which will present in any key inside JSON data.
I have tried using this.
db.getCollection('booking').find({'result.important_information': /.*small dogs*/})
But this required key for search But I dont have key name I have to search using the only value.

Firestore data usage

In firestore I can have Field and Collection together in a Document. Let's say I want to fetch only the fields of a document. I will do it in the following way.
this.afs.collection('coll1').document('document1').ref.get().then(x=>{
colsole.log(x.data());
});
Now x.data() is only showing me the fields only, not the collection which is correct. But in the background is it downloading all data of the document. As I don't need all the data it will be an extra data usage.