Skip to content

Commit 7d7ff8e

Browse files
committed
add inserting data snippets and run snippets
1 parent b447e27 commit 7d7ff8e

17 files changed

Lines changed: 318 additions & 0 deletions

firestore-temp/test.firestore.js

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2125,6 +2125,51 @@ describe("firestore-pipelines", () => {
21252125
console.log(result);
21262126
}
21272127

2128+
async function searchBasicQueryData() {
2129+
// [START search_basic_query_data]
2130+
await db.collection("Restaurants").add({
2131+
name: "Waffle Place",
2132+
description: "A cozy place for fresh waffles."
2133+
});
2134+
// [END search_basic_query_data]
2135+
}
2136+
2137+
async function searchExactMatchData() {
2138+
// [START search_exact_match_data]
2139+
await db.collection("Restaurants").add({
2140+
name: "Waffle Place",
2141+
description: "A cozy place for fresh waffles."
2142+
});
2143+
// [END search_exact_match_data]
2144+
}
2145+
2146+
async function searchTwoTermsData() {
2147+
// [START search_two_terms_data]
2148+
await db.collection("Restaurants").add({
2149+
name: "Morning Diner",
2150+
description: "Start your day with waffles and eggs."
2151+
});
2152+
// [END search_two_terms_data]
2153+
}
2154+
2155+
async function searchExcludeTermData() {
2156+
// [START search_exclude_term_data]
2157+
await db.collection("Restaurants").add({
2158+
name: "City Coffee",
2159+
description: "Premium coffee and pastries."
2160+
});
2161+
// [END search_exclude_term_data]
2162+
}
2163+
2164+
async function searchScoreData() {
2165+
// [START search_score_data]
2166+
await db.collection("Restaurants").add({
2167+
name: "The Waffle Hub",
2168+
description: "Everything waffles!"
2169+
});
2170+
// [END search_score_data]
2171+
}
2172+
21282173
async function searchExamples() {
21292174
// [START search_example]
21302175
await db.pipeline().collection('restaurants')
@@ -2169,6 +2214,51 @@ describe("firestore-pipelines", () => {
21692214
// [END search_score_field]
21702215
}
21712216

2217+
async function defineStageData() {
2218+
// [START define_stage_data]
2219+
await db.collection("Authors").doc("author_123").set({
2220+
id: "author_123",
2221+
name: "Jane Austen"
2222+
});
2223+
// [END define_stage_data]
2224+
}
2225+
2226+
async function toArrayExpressionStageData() {
2227+
// [START to_array_expression_stage_data]
2228+
await db.collection("Projects").doc("project_1").set({
2229+
id: "project_1",
2230+
name: "Alpha Build"
2231+
});
2232+
await db.collection("Tasks").add({
2233+
project_id: "project_1",
2234+
title: "System Architecture"
2235+
});
2236+
await db.collection("Tasks").add({
2237+
project_id: "project_1",
2238+
title: "Database Schema Design"
2239+
});
2240+
// [END to_array_expression_stage_data]
2241+
}
2242+
2243+
async function toScalarExpressionStageData() {
2244+
// [START to_scalar_expression_stage_data]
2245+
await db.collection("Authors").doc("author_202").set({
2246+
id: "author_202",
2247+
name: "Charles Dickens"
2248+
});
2249+
await db.collection("Books").add({
2250+
author_id: "author_202",
2251+
title: "Great Expectations",
2252+
rating: 4.8
2253+
});
2254+
await db.collection("Books").add({
2255+
author_id: "author_202",
2256+
title: "Oliver Twist",
2257+
rating: 4.5
2258+
});
2259+
// [END to_scalar_expression_stage_data]
2260+
}
2261+
21722262
async function subqueryExamples() {
21732263
// [START define_example]
21742264
const result = await db.pipeline().collection("authors")
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// This snippet file was generated by processing the source file:
2+
// ./firestore-next/test.firestore.js
3+
//
4+
// To update the snippets in this file, edit the source and then run
5+
// 'npm run snippets'.
6+
7+
// [START define_stage_data_modular]
8+
await setDoc(doc(collection(db, "Authors"), "author_123"), {
9+
"id": "author_123",
10+
"name": "Jane Austen"
11+
});
12+
// [END define_stage_data_modular]
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// This snippet file was generated by processing the source file:
2+
// ./firestore-next/test.firestore.js
3+
//
4+
// To update the snippets in this file, edit the source and then run
5+
// 'npm run snippets'.
6+
7+
// [START search_basic_query_data_modular]
8+
await addDoc(collection(db, "Restaurants"), {
9+
"name": "Waffle Place",
10+
"description": "A cozy place for fresh waffles."
11+
});
12+
// [END search_basic_query_data_modular]
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// This snippet file was generated by processing the source file:
2+
// ./firestore-next/test.firestore.js
3+
//
4+
// To update the snippets in this file, edit the source and then run
5+
// 'npm run snippets'.
6+
7+
// [START search_exact_match_data_modular]
8+
await addDoc(collection(db, "Restaurants"), {
9+
"name": "Waffle Place",
10+
"description": "A cozy place for fresh waffles."
11+
});
12+
// [END search_exact_match_data_modular]
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// This snippet file was generated by processing the source file:
2+
// ./firestore-next/test.firestore.js
3+
//
4+
// To update the snippets in this file, edit the source and then run
5+
// 'npm run snippets'.
6+
7+
// [START search_exclude_term_data_modular]
8+
await addDoc(collection(db, "Restaurants"), {
9+
"name": "City Coffee",
10+
"description": "Premium coffee and pastries."
11+
});
12+
// [END search_exclude_term_data_modular]
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// This snippet file was generated by processing the source file:
2+
// ./firestore-next/test.firestore.js
3+
//
4+
// To update the snippets in this file, edit the source and then run
5+
// 'npm run snippets'.
6+
7+
// [START search_score_data_modular]
8+
await addDoc(collection(db, "Restaurants"), {
9+
"name": "The Waffle Hub",
10+
"description": "Everything waffles!"
11+
});
12+
// [END search_score_data_modular]
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// This snippet file was generated by processing the source file:
2+
// ./firestore-next/test.firestore.js
3+
//
4+
// To update the snippets in this file, edit the source and then run
5+
// 'npm run snippets'.
6+
7+
// [START search_two_terms_data_modular]
8+
await addDoc(collection(db, "Restaurants"), {
9+
"name": "Morning Diner",
10+
"description": "Start your day with waffles and eggs."
11+
});
12+
// [END search_two_terms_data_modular]
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// This snippet file was generated by processing the source file:
2+
// ./firestore-next/test.firestore.js
3+
//
4+
// To update the snippets in this file, edit the source and then run
5+
// 'npm run snippets'.
6+
7+
// [START to_array_expression_stage_data_modular]
8+
await setDoc(doc(collection(db, "Projects"), "project_1"), {
9+
"id": "project_1",
10+
"name": "Alpha Build"
11+
});
12+
await addDoc(collection(db, "Tasks"), {
13+
"project_id": "project_1",
14+
"title": "System Architecture"
15+
});
16+
await addDoc(collection(db, "Tasks"), {
17+
"project_id": "project_1",
18+
"title": "Database Schema Design"
19+
});
20+
// [END to_array_expression_stage_data_modular]
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// This snippet file was generated by processing the source file:
2+
// ./firestore-next/test.firestore.js
3+
//
4+
// To update the snippets in this file, edit the source and then run
5+
// 'npm run snippets'.
6+
7+
// [START to_scalar_expression_stage_data_modular]
8+
await setDoc(doc(collection(db, "Authors"), "author_202"), {
9+
"id": "author_202",
10+
"name": "Charles Dickens"
11+
});
12+
await addDoc(collection(db, "Books"), {
13+
"author_id": "author_202",
14+
"title": "Great Expectations",
15+
"rating": 4.8
16+
});
17+
await addDoc(collection(db, "Books"), {
18+
"author_id": "author_202",
19+
"title": "Oliver Twist",
20+
"rating": 4.5
21+
});
22+
// [END to_scalar_expression_stage_data_modular]
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// This snippet file was generated by processing the source file:
2+
// ./firestore-temp/test.firestore.js
3+
//
4+
// To update the snippets in this file, edit the source and then run
5+
// 'npm run snippets'.
6+
7+
// [START define_stage_data_modular]
8+
await db.collection("Authors").doc("author_123").set({
9+
id: "author_123",
10+
name: "Jane Austen"
11+
});
12+
// [END define_stage_data_modular]

0 commit comments

Comments
 (0)