google-cloud-firestore

Need help searching for a value in firestore

≯℡__Kan透↙ 提交于 2021-02-05 10:44:05
问题 I'm new to firestore and I'm making a register page with vue. Before a new user is made, it has to check if the given username already exists or not and if not, make a new user. I can add a new user to the database, but I don't know how to check if the username already exists or not. I tried a lot of things and this is the closest I've gotten: db.collection("Users") .get() .then(querySnapshot => { querySnapshot.forEach(doc => { if (this.username === doc.data().username) { usernameExist = true

Using the Firestore REST API to Update a Document Field

梦想的初衷 提交于 2021-02-05 10:42:51
问题 I've been searching for a pretty long time but I can't figure out how to update a field in a document using the Firestore REST API. I've looked on other questions but they haven't helped me since I'm getting a different error: {'error': {'code': 400, 'message': 'Request contains an invalid argument.', 'status': 'INVALID_ARGUMENT', 'details': [{'@type': 'type.googleapis.com/google.rpc.BadRequest', 'fieldViolations': [{'field': 'oil', 'description': "Error expanding 'fields' parameter. Cannot

Firestore - How can I use DocumentReference to point a document from another project?

Deadly 提交于 2021-02-05 09:44:59
问题 As far as I know firebase.firestore.DocumentReference<T> can point to a document within the current project. Is it possible to point a document from another project? It is reasonable to have such ability because Firebase already has written a document to share how to use multiple projects within an app. 回答1: Is it possible to point a document from another project? Yes it is possible. The following code shows how to use a value from the Firestore DB of one primary project in order to query the

Firestore - How can I use DocumentReference to point a document from another project?

♀尐吖头ヾ 提交于 2021-02-05 09:44:06
问题 As far as I know firebase.firestore.DocumentReference<T> can point to a document within the current project. Is it possible to point a document from another project? It is reasonable to have such ability because Firebase already has written a document to share how to use multiple projects within an app. 回答1: Is it possible to point a document from another project? Yes it is possible. The following code shows how to use a value from the Firestore DB of one primary project in order to query the

Firestore - How can I use DocumentReference to point a document from another project?

隐身守侯 提交于 2021-02-05 09:43:31
问题 As far as I know firebase.firestore.DocumentReference<T> can point to a document within the current project. Is it possible to point a document from another project? It is reasonable to have such ability because Firebase already has written a document to share how to use multiple projects within an app. 回答1: Is it possible to point a document from another project? Yes it is possible. The following code shows how to use a value from the Firestore DB of one primary project in order to query the

Get current server Date and Time in Firebase Firestore

北城余情 提交于 2021-02-05 09:39:16
问题 I want to get my server time in Firebase Firestore so I can use it for my countdown logic. I can't find anywhere and mostly they suggest to use FiedValue.serverTimeStamp or ServerValue.TIMESTAMP which is both are used to save data. I don't want to save data I just want to get the server time. Is there a static way like FirebaseFirestore.getInstance().getServerTime() ? 回答1: As per said by the @Doug there is no way of getting just only time from Firebase. However there are many round-ways for

Get current server Date and Time in Firebase Firestore

谁说我不能喝 提交于 2021-02-05 09:37:23
问题 I want to get my server time in Firebase Firestore so I can use it for my countdown logic. I can't find anywhere and mostly they suggest to use FiedValue.serverTimeStamp or ServerValue.TIMESTAMP which is both are used to save data. I don't want to save data I just want to get the server time. Is there a static way like FirebaseFirestore.getInstance().getServerTime() ? 回答1: As per said by the @Doug there is no way of getting just only time from Firebase. However there are many round-ways for

Does updating one field will download the whole document from the database or just update local version?

為{幸葍}努か 提交于 2021-02-05 09:36:24
问题 For example the document contains the following structure: { fieldA: number, fieldB: { subFieldA: string, subFieldB: string, } } ... and is being listened with the onSnapshot method. FirebaseDb .collection(`someCollection`).doc('documentAbove') .onSnapshot({ includeMetadataChanges: true }, (snapshot) => { // when the document being modified it becomes available at this stage }) My question is if when the document will be modified will the firestore download it once again? 回答1: Yes, the

Does updating one field will download the whole document from the database or just update local version?

时间秒杀一切 提交于 2021-02-05 09:36:16
问题 For example the document contains the following structure: { fieldA: number, fieldB: { subFieldA: string, subFieldB: string, } } ... and is being listened with the onSnapshot method. FirebaseDb .collection(`someCollection`).doc('documentAbove') .onSnapshot({ includeMetadataChanges: true }, (snapshot) => { // when the document being modified it becomes available at this stage }) My question is if when the document will be modified will the firestore download it once again? 回答1: Yes, the

How to return failed task result in continuation task?

↘锁芯ラ 提交于 2021-02-05 09:36:13
问题 I am using Google's Task API in Kotlin and am faced with the next situation: ... val deleteTask = getItem(id)?.continueWithTask { task -> if (task.isSuccessful) task.result?.toObject(ItemModel::class.java)?.let { deleteFiles(it.media) } } deleteTask?.continueWithTask { task -> if (task.isSuccessful) doSomething() } ?: doSomething() ... Where getItem(id) returns the Firebase.firestore get task ( Task<DocumentSnapshot>? ) and deleteFiles(it.media) retuens the Firebase.storage delete task ( Task