Documentation
¶
Index ¶
- Variables
- func MarshalQuerySpecJSON(query QuerySpec) ([]byte, error)
- func MarshalWireDocument(document Document) ([]byte, error)
- func MarshalWireValue(value Value) ([]byte, error)
- func ValidateStrictJSON(data []byte, maxBytes int) error
- type Change
- type ChangeBatch
- type Collection
- func (c *Collection) CreateIndex(ctx context.Context, name string, fields []IndexField, options IndexOptions) error
- func (c *Collection) DeleteMany(ctx context.Context, filter Filter) (DeleteResult, error)
- func (c *Collection) DeleteManyQuery(ctx context.Context, query QuerySpec) (DeleteResult, error)
- func (c *Collection) DeleteManyQueryLimited(ctx context.Context, query QuerySpec, maxAffected int) (DeleteResult, error)
- func (c *Collection) DeleteOne(ctx context.Context, filter Filter) (DeleteResult, error)
- func (c *Collection) DeleteOneQuery(ctx context.Context, query QuerySpec) (DeleteResult, error)
- func (c *Collection) Explain(ctx context.Context, filter Filter) (ExplainResult, error)
- func (c *Collection) Find(ctx context.Context, filter Filter, options ...QueryOptions) (*Cursor, error)
- func (c *Collection) FindOne(ctx context.Context, filter Filter) (Document, error)
- func (c *Collection) FindQuery(ctx context.Context, query QuerySpec) (*Cursor, error)
- func (c *Collection) InsertMany(ctx context.Context, documents []Document) ([]DocumentID, error)
- func (c *Collection) InsertOne(ctx context.Context, document Document) (DocumentID, error)
- func (c *Collection) SnapshotQuery(ctx context.Context, query QuerySpec) (QuerySnapshot, error)
- func (c *Collection) SubscribeQuery(ctx context.Context, query QuerySpec, buffer int) (*QuerySubscription, error)
- func (c *Collection) UpdateMany(ctx context.Context, filter Filter, update Update) (UpdateResult, error)
- func (c *Collection) UpdateManyQuery(ctx context.Context, query QuerySpec, mutation MutationSpec) (UpdateResult, error)
- func (c *Collection) UpdateManyQueryLimited(ctx context.Context, query QuerySpec, mutation MutationSpec, maxAffected int) (UpdateResult, error)
- func (c *Collection) UpdateOne(ctx context.Context, filter Filter, update Update) (UpdateResult, error)
- func (c *Collection) UpdateOneQuery(ctx context.Context, query QuerySpec, mutation MutationSpec) (UpdateResult, error)
- type Cursor
- type DB
- func (db *DB) CanResumeFrom(token uint64) bool
- func (db *DB) Close() error
- func (db *DB) Collection(name string) *Collection
- func (db *DB) DatabaseIdentity() [16]byte
- func (db *DB) Sync() error
- func (db *DB) WatchChanges(ctx context.Context, collection string, buffer int) (<-chan ChangeBatch, <-chan error, error)
- type DeleteResult
- type Document
- type DocumentID
- type ExplainResult
- type Filter
- type IndexDefinition
- type IndexField
- type IndexOptions
- type Kind
- type MutationSpec
- type Operation
- type QueryLimits
- type QueryOptions
- type QuerySnapshot
- type QuerySpec
- func (q QuerySpec) Capped(max int) QuerySpec
- func (q QuerySpec) Constrain(policy QuerySpec) QuerySpec
- func (q QuerySpec) Execute(documents []Document) []Document
- func (q QuerySpec) HasModifiers() bool
- func (q QuerySpec) Limit() (int, bool)
- func (q QuerySpec) Match(document Document) bool
- func (q QuerySpec) Paths() []string
- func (q QuerySpec) Skip() int
- func (q QuerySpec) Sort() []SortField
- type QuerySubscription
- type SortField
- type Update
- type UpdateResult
- type Value
- func Array(v ...Value) Value
- func Binary(v []byte) Value
- func Bool(v bool) Value
- func Float(v float64) Value
- func ID(v DocumentID) Value
- func Int(v int64) Value
- func Null() Value
- func Object(v Document) Value
- func String(v string) Value
- func Time(v time.Time) Value
- func ValueOf(x any) (Value, error)
- func (v Value) ArrayValue() ([]Value, bool)
- func (v Value) BinaryValue() ([]byte, bool)
- func (v Value) Bool() (bool, bool)
- func (v Value) Clone() Value
- func (v Value) Equal(other Value) bool
- func (v Value) Float64() (float64, bool)
- func (v Value) IDValue() (DocumentID, bool)
- func (v Value) Int64() (int64, bool)
- func (v Value) Kind() Kind
- func (v Value) ObjectValue() (Document, bool)
- func (v Value) StringValue() (string, bool)
- func (v Value) TimeValue() (time.Time, bool)
Constants ¶
This section is empty.
Variables ¶
var ( ErrClosed = errors.New("meldbase: database is closed") ErrInvalidDocument = errors.New("meldbase: invalid document") ErrInvalidFilter = errors.New("meldbase: invalid filter") ErrInvalidUpdate = errors.New("meldbase: invalid update") ErrMutationLimit = errors.New("meldbase: mutation affected-row limit exceeded") ErrNotFound = errors.New("meldbase: document not found") ErrDuplicateID = errors.New("meldbase: duplicate document id") ErrInvalidCollection = errors.New("meldbase: invalid collection") ErrImmutableID = errors.New("meldbase: _id is immutable") ErrSlowConsumer = errors.New("meldbase: change consumer is too slow") ErrCorrupt = errors.New("meldbase: corrupt database") ErrDuplicateKey = errors.New("meldbase: duplicate index key") ErrInvalidIndex = errors.New("meldbase: invalid index") ErrDurability = errors.New("meldbase: durability failure; writes are disabled") )
var DefaultQueryLimits = QueryLimits{
MaxWireBytes: 1 << 20, MaxDepth: 16, MaxNodes: 128,
MaxArrayItems: 256, MaxValueBytes: 16_384, MaxSortFields: 4,
MaxLimit: 10_000,
}
Functions ¶
func MarshalQuerySpecJSON ¶
MarshalQuerySpecJSON emits the canonical, data-only wire representation used for transport fingerprints and cross-language conformance.
func MarshalWireDocument ¶
func MarshalWireValue ¶
func ValidateStrictJSON ¶
ValidateStrictJSON rejects oversized, trailing, deeply nested, and duplicate-key JSON before a transport decodes it into structs or maps.
Types ¶
type Change ¶
type Change struct {
Collection string
Operation Operation
DocumentID DocumentID
Before *Document
After *Document
Index *IndexDefinition
}
type ChangeBatch ¶
type Collection ¶
type Collection struct {
// contains filtered or unexported fields
}
func (*Collection) CreateIndex ¶
func (c *Collection) CreateIndex(ctx context.Context, name string, fields []IndexField, options IndexOptions) error
func (*Collection) DeleteMany ¶
func (c *Collection) DeleteMany(ctx context.Context, filter Filter) (DeleteResult, error)
func (*Collection) DeleteManyQuery ¶
func (c *Collection) DeleteManyQuery(ctx context.Context, query QuerySpec) (DeleteResult, error)
func (*Collection) DeleteManyQueryLimited ¶
func (c *Collection) DeleteManyQueryLimited(ctx context.Context, query QuerySpec, maxAffected int) (DeleteResult, error)
DeleteManyQueryLimited atomically rejects the whole mutation when more than maxAffected documents match.
func (*Collection) DeleteOne ¶
func (c *Collection) DeleteOne(ctx context.Context, filter Filter) (DeleteResult, error)
func (*Collection) DeleteOneQuery ¶
func (c *Collection) DeleteOneQuery(ctx context.Context, query QuerySpec) (DeleteResult, error)
func (*Collection) Explain ¶
func (c *Collection) Explain(ctx context.Context, filter Filter) (ExplainResult, error)
func (*Collection) Find ¶
func (c *Collection) Find(ctx context.Context, filter Filter, options ...QueryOptions) (*Cursor, error)
func (*Collection) InsertMany ¶
func (c *Collection) InsertMany(ctx context.Context, documents []Document) ([]DocumentID, error)
InsertMany validates IDs, documents, and all unique-index keys before writing one WAL record. Either the entire batch becomes visible or none of it does.
func (*Collection) InsertOne ¶
func (c *Collection) InsertOne(ctx context.Context, document Document) (DocumentID, error)
func (*Collection) SnapshotQuery ¶
func (c *Collection) SnapshotQuery(ctx context.Context, query QuerySpec) (QuerySnapshot, error)
func (*Collection) SubscribeQuery ¶
func (c *Collection) SubscribeQuery(ctx context.Context, query QuerySpec, buffer int) (*QuerySubscription, error)
func (*Collection) UpdateMany ¶
func (c *Collection) UpdateMany(ctx context.Context, filter Filter, update Update) (UpdateResult, error)
func (*Collection) UpdateManyQuery ¶
func (c *Collection) UpdateManyQuery(ctx context.Context, query QuerySpec, mutation MutationSpec) (UpdateResult, error)
func (*Collection) UpdateManyQueryLimited ¶
func (c *Collection) UpdateManyQueryLimited(ctx context.Context, query QuerySpec, mutation MutationSpec, maxAffected int) (UpdateResult, error)
UpdateManyQueryLimited atomically rejects the whole mutation when more than maxAffected documents match. A non-positive limit is invalid here so callers cannot accidentally disable a server-owned safety bound.
func (*Collection) UpdateOne ¶
func (c *Collection) UpdateOne(ctx context.Context, filter Filter, update Update) (UpdateResult, error)
func (*Collection) UpdateOneQuery ¶
func (c *Collection) UpdateOneQuery(ctx context.Context, query QuerySpec, mutation MutationSpec) (UpdateResult, error)
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
func (*DB) CanResumeFrom ¶
func (*DB) Collection ¶
func (db *DB) Collection(name string) *Collection
func (*DB) DatabaseIdentity ¶
func (*DB) WatchChanges ¶
type DeleteResult ¶
type DeleteResult struct{ DeletedCount int64 }
type Document ¶
func UnmarshalWireDocument ¶
func UnmarshalWireDocument(data []byte, limits QueryLimits) (Document, error)
func UnmarshalWireInputDocument ¶
func UnmarshalWireInputDocument(data []byte, limits QueryLimits) (Document, error)
func (Document) ID ¶
func (d Document) ID() (DocumentID, bool)
type DocumentID ¶
type DocumentID [16]byte
func NewDocumentID ¶
func NewDocumentID() (DocumentID, error)
func ParseDocumentID ¶
func ParseDocumentID(s string) (DocumentID, error)
func (DocumentID) IsZero ¶
func (id DocumentID) IsZero() bool
func (DocumentID) String ¶
func (id DocumentID) String() string
type ExplainResult ¶
type IndexDefinition ¶
type IndexField ¶
type IndexOptions ¶
type IndexOptions struct{ Unique bool }
type MutationSpec ¶
type MutationSpec struct {
// contains filtered or unexported fields
}
func CompileUpdate ¶
func CompileUpdate(update Update) (MutationSpec, error)
func DecodeMutationSpecJSON ¶
func DecodeMutationSpecJSON(data []byte, limits QueryLimits) (MutationSpec, error)
func (MutationSpec) Paths ¶
func (m MutationSpec) Paths() []string
type QueryLimits ¶
type QueryOptions ¶
type QuerySnapshot ¶
type QuerySpec ¶
type QuerySpec struct {
// contains filtered or unexported fields
}
func CompileQuery ¶
func CompileQuery(filter Filter, options QueryOptions) (QuerySpec, error)
func DecodeQuerySpecJSON ¶
func DecodeQuerySpecJSON(data []byte, limits QueryLimits) (QuerySpec, error)
func (QuerySpec) Constrain ¶
Constrain applies a server-owned row predicate before the caller's sort and pagination. This is the safe composition point for authorization policies.
func (QuerySpec) HasModifiers ¶
type QuerySubscription ¶
type QuerySubscription struct {
Snapshots <-chan QuerySnapshot
Errors <-chan error
// contains filtered or unexported fields
}
func (*QuerySubscription) Close ¶
func (s *QuerySubscription) Close()
type UpdateResult ¶
type UpdateResult struct{ MatchedCount, ModifiedCount int64 }
type Value ¶
type Value struct {
// contains filtered or unexported fields
}
Value is a closed tagged value. Its representation is private so callers cannot construct a tag/payload mismatch.
func ID ¶
func ID(v DocumentID) Value
func Time ¶
Time stores millisecond precision, matching JavaScript Date and the wire contract. Precision is normalized at construction rather than silently lost during transport.
func (Value) ArrayValue ¶
func (Value) BinaryValue ¶
func (Value) IDValue ¶
func (v Value) IDValue() (DocumentID, bool)