-
Notifications
You must be signed in to change notification settings - Fork 253
/
Copy pathtest.solution-arrays.js
86 lines (79 loc) · 2.38 KB
/
test.solution-arrays.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import firebase from 'firebase/app';
import 'firebase/firestore';
const postsWithArray = [
// [START post_with_array]
// Sample document in the 'posts' collection.
{
title: "My great post",
categories: [
"technology",
"opinion",
"cats"
]
}
// [END post_with_array]
];
const postsWithMap = [
// [START post_with_map]
// Sample document in the 'posts' collection
{
title: "My great post",
categories: {
"technology": true,
"opinion": true,
"cats": true
}
}
// [END post_with_map]
];
const postsWithMapAdvanced = [
// [START post_with_map_advanced]
// The value of each entry in 'categories' is a unix timestamp
{
title: "My great post",
categories: {
technology: 1502144665,
opinion: 1502144665,
cats: 1502144665
}
}
// [END post_with_map_advanced]
];
describe("firestore-solution-arrays", () => {
var db;
before(() => {
var config = {
apiKey: "AIzaSyArvVh6VSdXicubcvIyuB-GZs8ua0m0DTI",
authDomain: "firestorequickstarts.firebaseapp.com",
projectId: "firestorequickstarts",
};
var app = firebase.initializeApp(config, "solution-arrays");
db = firebase.firestore(app);
});
describe("solution-arrays", () => {
it("should query in a category #UNVERIFIED", () => {
// [START query_in_category]
// Find all documents in the 'posts' collection that are
// in the 'cats' category.
db.collection('posts')
.where('categories.cats', '==', true)
.get()
.then(() => {
// ...
});
// [END query_in_category]
});
it("should query in a category by timestamp #UNVERIFIED", () => {
// [START query_in_category_timestamp_invalid]
db.collection('posts')
.where('categories.cats', '==', true)
.orderBy('timestamp');
// [END query_in_category_timestamp_invalid]
// [START query_in_category_timestamp]
db.collection('posts')
.where('categories.cats', '>', 0)
.orderBy('categories.cats');
// [END query_in_category_timestamp]
});
});
});