Documentation
¶
Overview ¶
Package zerodb provides a client for ZeroDB NoSQL table operations.
The zerodb package implements:
- Table creation with schema definition
- Document insertion with validation
- MongoDB-style query filtering
- Document updates and deletions
- Table listing and management
Basic Usage:
client := zerodb.New(
zerodb.WithAPIClient(apiClient),
zerodb.WithProjectID("my-project"),
)
// Create a table
err := client.CreateTable(ctx, "users", schema)
// Insert documents
id, err := client.Insert(ctx, "users", document)
// Query documents
results, err := client.Query(ctx, "users", filter)
// Update document
err = client.Update(ctx, "users", id, updates)
// Delete document
err = client.Delete(ctx, "users", id)
Index ¶
- type Client
- func (c *Client) ClearMemory(ctx context.Context, req *MemoryClearRequest) (*MemoryClearResponse, error)
- func (c *Client) CreateCollection(ctx context.Context, name string, dimensions int, metric string) (*VectorCollection, error)
- func (c *Client) CreateTable(ctx context.Context, name string, schema map[string]interface{}) (*Table, error)
- func (c *Client) Delete(ctx context.Context, tableName string, id string) error
- func (c *Client) DeleteVector(ctx context.Context, collection string, id string) error
- func (c *Client) Insert(ctx context.Context, tableName string, data map[string]interface{}) (string, *Document, error)
- func (c *Client) InsertVector(ctx context.Context, collection string, vector []float64, ...) (string, *Vector, error)
- func (c *Client) ListCollections(ctx context.Context) ([]*VectorCollection, error)
- func (c *Client) ListMemory(ctx context.Context, req *MemoryListRequest) ([]*Memory, int, error)
- func (c *Client) ListTables(ctx context.Context) ([]*Table, error)
- func (c *Client) QuantumCompress(ctx context.Context, vectorID string, compressionRatio float64) (*QuantumCompressResponse, error)
- func (c *Client) QuantumDecompress(ctx context.Context, vectorID string) (*QuantumDecompressResponse, error)
- func (c *Client) QuantumEntangle(ctx context.Context, vectorID1, vectorID2 string) (*QuantumEntangleResponse, error)
- func (c *Client) QuantumMeasure(ctx context.Context, vectorID string) (*QuantumMeasureResponse, error)
- func (c *Client) QuantumSearch(ctx context.Context, req *QuantumSearchRequest) ([]*QuantumSearchResult, error)
- func (c *Client) Query(ctx context.Context, tableName string, filter QueryFilter, ...) ([]*Document, error)
- func (c *Client) RetrieveMemory(ctx context.Context, req *MemoryRetrieveRequest) ([]*Memory, error)
- func (c *Client) SearchVectors(ctx context.Context, collection string, queryVector []float64, limit int, ...) ([]*Vector, error)
- func (c *Client) StoreMemory(ctx context.Context, req *MemoryStoreRequest) (*Memory, error)
- func (c *Client) Update(ctx context.Context, tableName string, id string, data map[string]interface{}) (*Document, error)
- type CreateCollectionRequest
- type CreateCollectionResponse
- type CreateTableRequest
- type CreateTableResponse
- type DeleteRequest
- type DeleteResponse
- type Document
- type InsertRequest
- type InsertResponse
- type ListCollectionsResponse
- type ListTablesResponse
- type Memory
- type MemoryClearRequest
- type MemoryClearResponse
- type MemoryListRequest
- type MemoryListResponse
- type MemoryRetrieveRequest
- type MemoryRetrieveResponse
- type MemoryStoreRequest
- type MemoryStoreResponse
- type Option
- type QuantumCompressRequest
- type QuantumCompressResponse
- type QuantumDecompressRequest
- type QuantumDecompressResponse
- type QuantumEntangleRequest
- type QuantumEntangleResponse
- type QuantumMeasureRequest
- type QuantumMeasureResponse
- type QuantumSearchRequest
- type QuantumSearchResponse
- type QuantumSearchResult
- type QuantumVector
- type QueryFilter
- type QueryOptions
- type QueryRequest
- type QueryResponse
- type Table
- type UpdateRequest
- type UpdateResponse
- type Vector
- type VectorCollection
- type VectorDeleteRequest
- type VectorDeleteResponse
- type VectorInsertRequest
- type VectorInsertResponse
- type VectorSearchRequest
- type VectorSearchResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client represents a client for ZeroDB NoSQL operations.
func (*Client) ClearMemory ¶
func (c *Client) ClearMemory(ctx context.Context, req *MemoryClearRequest) (*MemoryClearResponse, error)
ClearMemory clears agent memories.
func (*Client) CreateCollection ¶
func (c *Client) CreateCollection(ctx context.Context, name string, dimensions int, metric string) (*VectorCollection, error)
CreateCollection creates a new vector collection with the specified dimensions.
func (*Client) CreateTable ¶
func (c *Client) CreateTable(ctx context.Context, name string, schema map[string]interface{}) (*Table, error)
CreateTable creates a new NoSQL table with the specified schema.
func (*Client) DeleteVector ¶
DeleteVector deletes a vector from the specified collection.
func (*Client) Insert ¶
func (c *Client) Insert(ctx context.Context, tableName string, data map[string]interface{}) (string, *Document, error)
Insert inserts a new document into the specified table.
func (*Client) InsertVector ¶
func (c *Client) InsertVector(ctx context.Context, collection string, vector []float64, metadata map[string]interface{}, id string) (string, *Vector, error)
InsertVector inserts a new vector into the specified collection.
func (*Client) ListCollections ¶
func (c *Client) ListCollections(ctx context.Context) ([]*VectorCollection, error)
ListCollections lists all vector collections in the project.
func (*Client) ListMemory ¶
ListMemory lists agent memories.
func (*Client) ListTables ¶
ListTables lists all tables in the project.
func (*Client) QuantumCompress ¶
func (c *Client) QuantumCompress(ctx context.Context, vectorID string, compressionRatio float64) (*QuantumCompressResponse, error)
QuantumCompress compresses a vector using quantum compression techniques.
func (*Client) QuantumDecompress ¶
func (c *Client) QuantumDecompress(ctx context.Context, vectorID string) (*QuantumDecompressResponse, error)
QuantumDecompress decompresses a previously compressed vector.
func (*Client) QuantumEntangle ¶
func (c *Client) QuantumEntangle(ctx context.Context, vectorID1, vectorID2 string) (*QuantumEntangleResponse, error)
QuantumEntangle entangles two vectors to create a quantum correlation.
func (*Client) QuantumMeasure ¶
func (c *Client) QuantumMeasure(ctx context.Context, vectorID string) (*QuantumMeasureResponse, error)
QuantumMeasure measures the quantum state of a vector.
func (*Client) QuantumSearch ¶
func (c *Client) QuantumSearch(ctx context.Context, req *QuantumSearchRequest) ([]*QuantumSearchResult, error)
QuantumSearch performs quantum-enhanced vector similarity search.
func (*Client) Query ¶
func (c *Client) Query(ctx context.Context, tableName string, filter QueryFilter, options QueryOptions) ([]*Document, error)
Query queries documents from the specified table with optional filter.
func (*Client) RetrieveMemory ¶
RetrieveMemory retrieves agent memories using semantic search.
func (*Client) SearchVectors ¶
func (c *Client) SearchVectors(ctx context.Context, collection string, queryVector []float64, limit int, filter QueryFilter) ([]*Vector, error)
SearchVectors searches for vectors similar to the query vector.
func (*Client) StoreMemory ¶
StoreMemory stores agent memory content.
type CreateCollectionRequest ¶
type CreateCollectionRequest struct {
Name string `json:"name"`
Dimensions int `json:"dimensions"`
Metric string `json:"metric,omitempty"` // cosine (default), euclidean, dot_product
}
CreateCollectionRequest represents a request to create a vector collection.
type CreateCollectionResponse ¶
type CreateCollectionResponse struct {
Collection *VectorCollection `json:"collection"`
}
CreateCollectionResponse represents the response from creating a collection.
type CreateTableRequest ¶
type CreateTableRequest struct {
Name string `json:"name"`
Schema map[string]interface{} `json:"schema"`
}
CreateTableRequest represents a request to create a new table.
type CreateTableResponse ¶
type CreateTableResponse struct {
Table *Table `json:"table"`
}
CreateTableResponse represents the response from creating a table.
type DeleteRequest ¶
DeleteRequest represents a request to delete a document.
type DeleteResponse ¶
type DeleteResponse struct {
Success bool `json:"success"`
}
DeleteResponse represents the response from deleting a document.
type Document ¶
type Document struct {
ID string `json:"id"`
TableName string `json:"table_name"`
Data map[string]interface{} `json:"data"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
Document represents a document in a ZeroDB table.
type InsertRequest ¶
type InsertRequest struct {
TableName string `json:"table_name"`
Data map[string]interface{} `json:"data"`
}
InsertRequest represents a request to insert a document.
type InsertResponse ¶
InsertResponse represents the response from inserting a document.
type ListCollectionsResponse ¶
type ListCollectionsResponse struct {
Collections []*VectorCollection `json:"collections"`
Total int `json:"total"`
}
ListCollectionsResponse represents the response from listing vector collections.
type ListTablesResponse ¶
ListTablesResponse represents the response from listing tables.
type Memory ¶
type Memory struct {
ID string `json:"id"`
AgentID string `json:"agent_id"`
SessionID string `json:"session_id,omitempty"`
Content string `json:"content"`
Role string `json:"role,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
Similarity float64 `json:"similarity,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
Memory represents a stored memory entry for agent memory operations.
type MemoryClearRequest ¶
type MemoryClearRequest struct {
AgentID string `json:"agent_id"`
SessionID string `json:"session_id,omitempty"`
}
MemoryClearRequest represents a request to clear agent memories.
type MemoryClearResponse ¶
MemoryClearResponse represents the response from clearing memories.
type MemoryListRequest ¶
type MemoryListRequest struct {
AgentID string `json:"agent_id"`
SessionID string `json:"session_id,omitempty"`
Limit int `json:"limit,omitempty"`
Offset int `json:"offset,omitempty"`
}
MemoryListRequest represents a request to list agent memories.
type MemoryListResponse ¶
type MemoryListResponse struct {
Memories []*Memory `json:"memories"`
Total int `json:"total"`
Limit int `json:"limit"`
Offset int `json:"offset"`
}
MemoryListResponse represents the response from listing memories.
type MemoryRetrieveRequest ¶
type MemoryRetrieveRequest struct {
AgentID string `json:"agent_id"`
Query string `json:"query"`
Limit int `json:"limit,omitempty"`
SessionID string `json:"session_id,omitempty"`
}
MemoryRetrieveRequest represents a request to retrieve agent memories using semantic search.
type MemoryRetrieveResponse ¶
type MemoryRetrieveResponse struct {
Memories []*Memory `json:"memories"`
Total int `json:"total"`
}
MemoryRetrieveResponse represents the response from retrieving memories.
type MemoryStoreRequest ¶
type MemoryStoreRequest struct {
AgentID string `json:"agent_id"`
Content string `json:"content"`
Role string `json:"role,omitempty"`
SessionID string `json:"session_id,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
}
MemoryStoreRequest represents a request to store agent memory.
type MemoryStoreResponse ¶
type MemoryStoreResponse struct {
Memory *Memory `json:"memory"`
}
MemoryStoreResponse represents the response from storing memory.
type Option ¶
type Option func(*Client)
Option is a functional option for configuring the Client.
func WithAPIClient ¶
WithAPIClient sets the underlying HTTP API client.
func WithProjectID ¶
WithProjectID sets the ZeroDB project ID.
type QuantumCompressRequest ¶
type QuantumCompressRequest struct {
VectorID string `json:"vector_id"`
CompressionRatio float64 `json:"compression_ratio"`
}
QuantumCompressRequest represents a request to compress a vector using quantum techniques.
type QuantumCompressResponse ¶
type QuantumCompressResponse struct {
Vector *QuantumVector `json:"vector"`
OriginalDimension int `json:"original_dimension"`
CompressedDimension int `json:"compressed_dimension"`
CompressionRatio float64 `json:"compression_ratio"`
InformationLoss float64 `json:"information_loss"`
Message string `json:"message"`
}
QuantumCompressResponse represents the response from compressing a vector.
type QuantumDecompressRequest ¶
type QuantumDecompressRequest struct {
VectorID string `json:"vector_id"`
}
QuantumDecompressRequest represents a request to decompress a vector.
type QuantumDecompressResponse ¶
type QuantumDecompressResponse struct {
Vector *QuantumVector `json:"vector"`
OriginalDimension int `json:"original_dimension"`
DecompressedDimension int `json:"decompressed_dimension"`
RestorationAccuracy float64 `json:"restoration_accuracy"`
Message string `json:"message"`
}
QuantumDecompressResponse represents the response from decompressing a vector.
type QuantumEntangleRequest ¶
type QuantumEntangleRequest struct {
VectorID1 string `json:"vector_id_1"`
VectorID2 string `json:"vector_id_2"`
}
QuantumEntangleRequest represents a request to entangle two vectors.
type QuantumEntangleResponse ¶
type QuantumEntangleResponse struct {
Vector1 *QuantumVector `json:"vector_1"`
Vector2 *QuantumVector `json:"vector_2"`
EntanglementID string `json:"entanglement_id"`
CorrelationScore float64 `json:"correlation_score"`
Message string `json:"message"`
}
QuantumEntangleResponse represents the response from entangling vectors.
type QuantumMeasureRequest ¶
type QuantumMeasureRequest struct {
VectorID string `json:"vector_id"`
}
QuantumMeasureRequest represents a request to measure a quantum vector.
type QuantumMeasureResponse ¶
type QuantumMeasureResponse struct {
Vector *QuantumVector `json:"vector"`
QuantumState string `json:"quantum_state"`
Entropy float64 `json:"entropy"`
Coherence float64 `json:"coherence"`
Properties map[string]interface{} `json:"properties"`
}
QuantumMeasureResponse represents the response from measuring a vector.
type QuantumSearchRequest ¶
type QuantumSearchRequest struct {
QueryVector []float64 `json:"query_vector"`
Limit int `json:"limit,omitempty"`
UseQuantumBoost bool `json:"use_quantum_boost,omitempty"`
IncludeEntangled bool `json:"include_entangled,omitempty"`
Filters map[string]interface{} `json:"filters,omitempty"`
}
QuantumSearchRequest represents a request to perform quantum-enhanced vector search.
type QuantumSearchResponse ¶
type QuantumSearchResponse struct {
Results []*QuantumSearchResult `json:"results"`
Total int `json:"total"`
QuantumBoostUsed bool `json:"quantum_boost_used"`
SearchLatency float64 `json:"search_latency_ms"`
}
QuantumSearchResponse represents the response from quantum vector search.
type QuantumSearchResult ¶
type QuantumSearchResult struct {
Vector *QuantumVector `json:"vector"`
Similarity float64 `json:"similarity"`
QuantumSimilarity float64 `json:"quantum_similarity,omitempty"`
Rank int `json:"rank"`
}
QuantumSearchResult represents a single search result with quantum metrics.
type QuantumVector ¶
type QuantumVector struct {
ID string `json:"id"`
Vector []float64 `json:"vector"`
Dimension int `json:"dimension"`
IsEntangled bool `json:"is_entangled"`
EntangledWith []string `json:"entangled_with,omitempty"`
QuantumState string `json:"quantum_state,omitempty"`
CompressionRatio float64 `json:"compression_ratio,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
QuantumVector represents a quantum-enhanced vector with entanglement state.
type QueryFilter ¶
type QueryFilter map[string]interface{}
QueryFilter represents a MongoDB-style query filter.
Examples:
// Simple equality
{"name": "John"}
// Comparison operators
{"age": {"$gt": 18, "$lt": 65}}
// Logical operators
{"$and": [{"age": {"$gte": 18}}, {"status": "active"}]}
// Array operators
{"tags": {"$in": ["go", "rust"]}}
// Existence check
{"email": {"$exists": true}}
type QueryOptions ¶
type QueryOptions struct {
Limit int `json:"limit,omitempty"`
Offset int `json:"offset,omitempty"`
Sort map[string]int `json:"sort,omitempty"` // 1 for asc, -1 for desc
Fields map[string]interface{} `json:"fields,omitempty"`
}
QueryOptions represents options for querying documents.
type QueryRequest ¶
type QueryRequest struct {
TableName string `json:"table_name"`
Filter QueryFilter `json:"filter,omitempty"`
Options QueryOptions `json:"options,omitempty"`
}
QueryRequest represents a request to query documents.
type QueryResponse ¶
type QueryResponse struct {
Documents []*Document `json:"documents"`
Total int `json:"total"`
Offset int `json:"offset"`
Limit int `json:"limit"`
}
QueryResponse represents the response from querying documents.
type Table ¶
type Table struct {
ID string `json:"id"`
Name string `json:"name"`
Schema map[string]interface{} `json:"schema"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
Table represents a ZeroDB NoSQL table.
type UpdateRequest ¶
type UpdateRequest struct {
TableName string `json:"table_name"`
ID string `json:"id"`
Data map[string]interface{} `json:"data"`
}
UpdateRequest represents a request to update a document.
type UpdateResponse ¶
type UpdateResponse struct {
Document *Document `json:"document"`
}
UpdateResponse represents the response from updating a document.
type Vector ¶
type Vector struct {
ID string `json:"id"`
Collection string `json:"collection"`
Vector []float64 `json:"vector"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
Score float64 `json:"score,omitempty"` // similarity score for search results
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
Vector represents a vector embedding with metadata.
type VectorCollection ¶
type VectorCollection struct {
ID string `json:"id"`
Name string `json:"name"`
Dimensions int `json:"dimensions"`
Metric string `json:"metric,omitempty"` // similarity metric (cosine, euclidean, dot_product)
Count int `json:"count,omitempty"` // number of vectors in collection
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
VectorCollection represents a vector collection for storing embeddings.
type VectorDeleteRequest ¶
VectorDeleteRequest represents a request to delete a vector.
type VectorDeleteResponse ¶
type VectorDeleteResponse struct {
Success bool `json:"success"`
}
VectorDeleteResponse represents the response from deleting a vector.
type VectorInsertRequest ¶
type VectorInsertRequest struct {
Collection string `json:"collection"`
Vector []float64 `json:"vector"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
ID string `json:"id,omitempty"` // optional ID for upsert behavior
}
VectorInsertRequest represents a request to insert a vector.
type VectorInsertResponse ¶
VectorInsertResponse represents the response from inserting a vector.
type VectorSearchRequest ¶
type VectorSearchRequest struct {
Collection string `json:"collection"`
QueryVector []float64 `json:"query_vector"`
Limit int `json:"limit,omitempty"`
Filter QueryFilter `json:"filter,omitempty"` // metadata filter
}
VectorSearchRequest represents a request to search for similar vectors.
type VectorSearchResponse ¶
VectorSearchResponse represents the response from searching vectors.