Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/firebase/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Firebase 如何将SQL转换为firestore查询_Firebase_Google Cloud Firestore_Database Schema - Fatal编程技术网

Firebase 如何将SQL转换为firestore查询

Firebase 如何将SQL转换为firestore查询,firebase,google-cloud-firestore,database-schema,Firebase,Google Cloud Firestore,Database Schema,我有这样一个查询语句: SELECT * FROM Customers WHERE (@ID IS NULL OR ID = @ID) AND (@Name IS NULL OR Name = @Name) 但我不知道在firestore里用它。你能帮助我吗。谢谢你Firestore在查询中没有等价的或条件,至少不是你在这里使用的类型。这是一个作为和工作的查询,而不是OP所寻找的或。 // Create a reference to the cities collection var cRe

我有这样一个查询语句:

SELECT * FROM Customers  WHERE (@ID IS NULL OR ID = @ID) AND (@Name IS NULL OR Name = @Name)

但我不知道在firestore里用它。你能帮助我吗。谢谢你

Firestore在查询中没有等价的
条件,至少不是你在这里使用的类型。这是一个作为
工作的查询,而不是OP所寻找的
// Create a reference to the cities collection
var cRef = db.collection("customers");

// Create a query against the collection.
var query = cRef.where("id", "in", [NULL,"YOURID"]).where("name", "in", [NULL,"YOURNAME"]);
query.get()
.then(function(querySnapshot) {
    querySnapshot.forEach(function(doc) {
        // doc.data() is never undefined for query doc snapshots
        console.log(doc.id, " => ", doc.data());
    });
})
.catch(function(error) {
    console.log("Error getting documents: ", error);
});