в облачном магазине пожаров
public class MapPost {
String title;
Map<String,Boolean> categories;
public MapPost(String title, Map<String,Boolean> categories) {
this.title = title;
this.categories = categories;
}
}
Map<String, Boolean> categories = new HashMap<>();
categories.put("technology", true);
categories.put("opinion", true);
categories.put("cats", true);
MapPost myMapPost = new MapPost("My great post", categories);
запрос, подобный этому
db.collection("posts")
.whereEqualTo("categories.cats", true)
.get()
.addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
// ...
});
Имеет ли база данных Firebase Realtime ту же функцию, что и Cloud Firestore, которая запрашивает данные, подобные массиву?
public class MapPost {
String title;
String body;
int starCount;
String uid;
Map<String,Boolean> stars;
public MapPost(String title, String body, int starCount, String body ,Map<String,Boolean> categories) {
this.title = title;
this.body = body;
this.starCount = starCount;
this.stars = stars;
}
}
--posts
----LC1inGwV9KXD
------body: "111"
------starCount:1
------stars
---------8prHpTdTHI2: true
------title: "test1"
------uid: "8tprHpTdTHI2"
Предполагается, что пользователь "8prHpTdTHI2" просмотрел 200 сообщений и 30 сообщений
в Cloud Firestore Я могу запросить 30 пост по
db.collection("posts")
.whereEqualTo("stars.8prHpTdTHI2", true)
.get()
.addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
// ...
});
я могу сделать это в Firebase?