ds9

module
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2025 License: Apache-2.0

README

ds9

ds9 logo

Go Reference Go Report Card Go Version

Zero-dependency Google Cloud Datastore client for Go. Drop-in replacement for cloud.google.com/go/datastore with CRUD, transactions, queries, cursors, and mutations. In-memory mock implementation. Comprehensive testing.

Why? The official client has 50+ dependencies. ds9 has zero—ideal for lightweight services and minimizing supply chain risk.

Installation

go get github.com/codeGROOVE-dev/ds9

Quick Start

This isn't the API we would choose, but our primary goal was a drop-in replacement, so usage is exactly the same as the cloud.google.com/go/datastore library:

import "github.com/codeGROOVE-dev/ds9/pkg/datastore"

client, _ := datastore.NewClient(ctx, "my-project")
key := datastore.NameKey("Task", "task-1", nil)
client.Put(ctx, key, &task)
client.Get(ctx, key, &task)

Migrating from cloud.google.com/go/datastore

Just switch the import path from cloud.google.com/go/datastore to github.com/codeGROOVE-dev/ds9/pkg/datastore.

Features

Supported Features

  • CRUD: Get, Put, Delete, GetMulti, PutMulti, DeleteMulti
  • Transactions: RunInTransaction, NewTransaction, Commit, Rollback
  • Queries: Filter, Order, Limit, Offset, Ancestor, Project, Distinct, DistinctOn, Namespace, Run (iterator), Count
  • Cursors: Start, End, DecodeCursor
  • Keys: NameKey, IDKey, IncompleteKey, AllocateIDs, parent keys
  • Mutations: NewInsert, NewUpdate, NewUpsert, NewDelete, Mutate
  • Errors: ErrNoSuchEntity, ErrInvalidKey, ErrInvalidEntityType, ErrConcurrentTransaction, Done, MultiError
  • Types: string, int, int64, int32, bool, float64, time.Time, slices ([]string, []int64, []int, []float64, []bool)

Unsupported Features

These features are unsupported just because we haven't found a use for the feature yet. PRs welcome:

  • Nested slices, map types, some advanced query features (streaming aggregations, OR filters).

Testing

  • Use datastore.NewMockClient(t) for in-memory testing. Works even if you're still using the official client.
  • See TESTING.md for integration tests.
  • We aim to maintain 85% test coverage - please don't send PRs without tests.

Directories

Path Synopsis
Package auth provides authentication for Google Cloud APIs.
Package auth provides authentication for Google Cloud APIs.
Package main demonstrates basic usage of the ds9 Datastore client.
Package main demonstrates basic usage of the ds9 Datastore client.
pkg
datastore
Package datastore provides a zero-dependency Google Cloud Datastore client.
Package datastore provides a zero-dependency Google Cloud Datastore client.
mock
Package mock provides an in-memory mock Datastore server for testing.
Package mock provides an in-memory mock Datastore server for testing.

Jump to

Keyboard shortcuts

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