protoc-gen-go-firestore

command module
v1.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 9, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

README

protoc-gen-go-firestore

Tests Linters Go Report Card Maintainability Go Reference

Exploration into generating Firestore bindings for Go from your .proto files.

Example

We generate a convenient API to read/write your protos from/to Firestore:

package main

import (
	"context"

	"cloud.google.com/go/firestore"
	servicev1 "github.com/myorg/apis-go/pkg/my/service/v1"
)

func main() {
	servicev1.Firestore(client()).
		Accounts().
		Doc("myid").
		Set(context.Background(), &servicev1.Account{
			Name: "myaccount",
		})
}

func client() *firestore.Client {
	c, err := firestore.NewClient(context.Background(), "project")
	if err != nil {
		panic(err)
	}
	return c
}

Given:

syntax = "proto3";
package my.service.v1;

import "firestore/options.proto";

option go_package = "github.com/myorg/apis-go/pkg/my/service/v1;servicev1";

message Account {
  option (firestore.message).collection = "accounts";
  string name = 1;
}

message User {
  option (firestore.message).collection = "accounts/{id}/users";
  string name = 1;
}

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
firestorepb module
internal
gen
version
Package version records versioning information about this module.
Package version records versioning information about this module.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL