This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static async Task AddData1(string project, string usersCollectionId) | |
{ | |
FirestoreDb db = FirestoreDb.Create(project); | |
// [START fs_add_data_1] | |
DocumentReference docRef = db.Collection(usersCollectionId).Document("alovelace"); | |
Dictionary<string, object> user = new Dictionary<string, object> | |
{ | |
{ "First", "Ada" }, | |
{ "Last", "Lovelace" }, | |
{ "Born", 1815 } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static async Task AddData1(string project) | |
{ | |
FirestoreDb db = FirestoreDb.Create(project); | |
// [START fs_add_data_1] | |
DocumentReference docRef = db.Collection("users").Document("alovelace"); | |
Dictionary<string, object> user = new Dictionary<string, object> | |
{ | |
{ "First", "Ada" }, | |
{ "Last", "Lovelace" }, | |
{ "Born", 1815 } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "google/cloud/firestore" | |
firestore = Google::Cloud::Firestore.new | |
city_ref = firestore.doc "cities/DC" | |
city_ref.delete |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ryanmats-macbookpro:firestore ryanmats$ bundle exec ruby delete_data.rb delete_collection | |
Deleting document LA. | |
/Library/Ruby/Gems/2.3.0/gems/google-cloud-firestore-0.21.0/lib/google/cloud/firestore/document_reference.rb:420:in `delete': undefined method `batch' for #<Google::Cloud::Firestore::CollectionReference:0x007fd232adba90> (NoMethodError) | |
from delete_data.rb:70:in `block in delete_collection' | |
from /Library/Ruby/Gems/2.3.0/gems/google-cloud-firestore-0.21.0/lib/google/cloud/firestore/query.rb:556:in `block in get' | |
from /Library/Ruby/Gems/2.3.0/gems/grpc-1.11.0-universal-darwin/src/ruby/lib/grpc/generic/active_call.rb:331:in `block in each_remote_read_then_finish' | |
from /Library/Ruby/Gems/2.3.0/gems/grpc-1.11.0-universal-darwin/src/ruby/lib/grpc/generic/active_call.rb:325:in `loop' | |
from /Library/Ruby/Gems/2.3.0/gems/grpc-1.11.0-universal-darwin/src/ruby/lib/grpc/generic/active_call.rb:325:in `each_remote_read_then_finish' | |
from /Library/Ruby/Gems/2.3.0/gems/google-cloud-firestore-0.21.0/lib/google/c |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "google/cloud/firestore" | |
firestore = Google::Cloud::Firestore.new(project_id: project_id) | |
cities_ref = firestore.col "cities" | |
query = cities_ref | |
query.get do |document_snapshot| | |
puts "Deleting document #{document_snapshot.document_id}." | |
document_ref = document_snapshot.ref | |
document_ref.delete |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "google/cloud/firestore" | |
firestore = Google::Cloud::Firestore.new | |
frank_ref = firestore.doc "users/frank" | |
frank_ref.set({ | |
name: "Frank", | |
favorites: { | |
food: "Pizza", | |
color: "Blue", | |
subject: "Recess" | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Project Sdk="Microsoft.NET.Sdk"> | |
<PropertyGroup> | |
<OutputType>Exe</OutputType> | |
<TargetFramework>netcoreapp2.0</TargetFramework> | |
<StartupObject>GoogleCloudSamples.QuickStartFirestoreProgram</StartupObject> | |
</PropertyGroup> | |
<ItemGroup> | |
<PackageReference Include="CommandLineParser" Version="2.1.1-beta" /> | |
<PackageReference Include="Google.Cloud.Firestore" Version="1.0.0-beta02" /> | |
</ItemGroup> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using CommandLine; | |
using Google.Cloud.Firestore; | |
using System; | |
using System.Collections; | |
using System.Collections.Generic; | |
using System.Threading.Tasks; | |
namespace GoogleCloudSamples | |
{ | |
public class QuickStartFirestoreProgram |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Unhandled Exception: System.AggregateException: One or more errors occurred. (Status(StatusCode=InvalidArgument, Detail="Entity has a nested entity property named 'Favorites' as well as a property prefixed with 'Favorites.', this results in name collision.")) ---> Grpc.Core.RpcException: Status(StatusCode=InvalidArgument, Detail="Entity has a nested entity property named 'Favorites' as well as a property prefixed with 'Favorites.', this results in name collision.") | |
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() | |
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) | |
at Google.Api.Gax.Grpc.ApiCallRetryExtensions.<>c__DisplayClass0_0`2.<<WithRetry>b__0>d.MoveNext() | |
--- End of stack trace from previous location where exception was thrown --- | |
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() | |
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) | |
at Google.Cloud.Firestore.WriteB |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Program.cs(77,53): error CS1061: 'CollectionReference' does not contain a definition for 'GetSnapshotAsync' and no extension method 'GetSnapshotAsync' accepting a first argument of type 'CollectionReference' could be found (are you missing a using directive or an assembly reference?) [/Users/ryanmats/testing/dotnet-docs-samples/firestore/api/QuickStartFirestore/QuickStartFirestore.csproj] | |
The build failed. Please fix the build errors and run again. |
NewerOlder