Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(firestore): Add firestore_query_filter_compound_multi_ineq to samples #27361

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions google-cloud-firestore/samples/query_data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def query_create_examples project_id:, collection_path: "cities"
state: "CA",
country: "USA",
capital: false,
density: 18_000,
population: 860_000,
regions: ["west_coast", "norcal"]
}
Expand All @@ -37,6 +38,7 @@ def query_create_examples project_id:, collection_path: "cities"
state: "CA",
country: "USA",
capital: false,
density: 8_300,
population: 3_900_000,
regions: ["west_coast", "socal"]
}
Expand All @@ -47,6 +49,7 @@ def query_create_examples project_id:, collection_path: "cities"
state: nil,
country: "USA",
capital: true,
density: 11_300,
population: 680_000,
regions: ["east_coast"]
}
Expand All @@ -57,6 +60,7 @@ def query_create_examples project_id:, collection_path: "cities"
state: nil,
country: "Japan",
capital: true,
density: 16_000,
population: 9_000_000,
regions: ["kanto", "honshu"]
}
Expand All @@ -67,6 +71,7 @@ def query_create_examples project_id:, collection_path: "cities"
state: nil,
country: "China",
capital: true,
density: 3_500,
population: 21_500_000,
regions: ["jingjinji", "hebei"]
}
Expand Down Expand Up @@ -183,6 +188,17 @@ def invalid_range_query project_id:, collection_path: "cities"
# [END firestore_query_filter_range_invalid]
end

def firestore_query_filter_compound_multi_ineq project_id:, collection_path: "cities"
# project_id = "Your Google Cloud Project ID"
# collection_path = "cities"

firestore = Google::Cloud::Firestore.new project_id: project_id
cities_ref = firestore.col collection_path
# [START firestore_query_filter_compound_multi_ineq]
invalid_range_query = cities_ref.where("population", ">", 1_000_000).where("density", "<", 1_000)
# [END firestore_query_filter_compound_multi_ineq]
end

def in_query_without_array project_id:, collection_path: "cities"
# project_id = "Your Google Cloud Project ID"
# collection_path = "cities"
Expand Down