Documentation
¶
Index ¶
- type Client
- func (client *Client) Close() error
- func (client *Client) Collections(ctx context.Context) ([]string, error)
- func (client *Client) Database(name ...string) *Database
- func (client *Client) Databases(ctx context.Context) ([]*Database, error)
- func (client *Client) Delete(ctx context.Context, collection any, filter ...*Filter) (int64, error)
- func (client *Client) DeleteMany(ctx context.Context, collection any, filter ...*Filter) (int64, error)
- func (client *Client) Do(ctx context.Context, fn func(context.Context) error) error
- func (client *Client) Exists(ctx context.Context, name string) bool
- func (client *Client) Find(ctx context.Context, doc any, sort *Sort, filter ...*Filter) error
- func (client *Client) FindMany(ctx context.Context, collection any, sort *Sort, filter ...*Filter) (*Cursor, error)
- func (client *Client) Insert(ctx context.Context, v any) (string, error)
- func (client *Client) InsertMany(ctx context.Context, v ...any) ([]string, error)
- func (client *Client) String() string
- func (client *Client) Timeout() time.Duration
- func (client *Client) Update(ctx context.Context, update any, filter ...*Filter) (int64, int64, error)
- type ClientOpt
- type Cursor
- type Database
- func (database *Database) Collections(ctx context.Context) ([]string, error)
- func (database *Database) Delete(ctx context.Context, collection any, filter ...*Filter) (int64, error)
- func (database *Database) DeleteMany(ctx context.Context, collection any, filter ...*Filter) (int64, error)
- func (database *Database) Find(ctx context.Context, doc any, sort *Sort, filter ...*Filter) error
- func (database *Database) FindMany(ctx context.Context, collection any, sort *Sort, filter ...*Filter) (*Cursor, error)
- func (database *Database) Insert(ctx context.Context, v any) (string, error)
- func (database *Database) InsertMany(ctx context.Context, v ...any) ([]string, error)
- func (database *Database) String() string
- func (database *Database) Update(ctx context.Context, update any, filter ...*Filter) (int64, int64, error)
- type Filter
- type Sort
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
func (*Client) Collections ¶
Collections returns the list of collections in the default database
func (*Client) Delete ¶
Delete deletes a single document from the collection and returns the number of documents deleted, which should be zero or one. At least one filter is needed in order to select the document to delete
func (*Client) DeleteMany ¶
func (client *Client) DeleteMany(ctx context.Context, collection any, filter ...*Filter) (int64, error)
DeleteMany deletes a zero or more documents from the collection and returns the number of documents deleted. At least one filter is needed in order to select the documents to delete
func (*Client) Do ¶
Do executes a series of statements within a transaction, and commits or rolls back depending on error returned
func (*Client) Find ¶
Find locates a document in the collection after filtering and sorting. Returns ErrNotFound if no document was found
func (*Client) FindMany ¶
func (client *Client) FindMany(ctx context.Context, collection any, sort *Sort, filter ...*Filter) (*Cursor, error)
FindMany returns in a collection based on filter and sort parameters, and returns an iteratable cursor to the result set. If more than one filter expression is provided, they are ANDed together
func (*Client) Insert ¶
Insert a single document to the database and return key for the document If writable, the document InsertID field is updated
func (*Client) InsertMany ¶
InsertMany inserts one or more documents of the same type to the database and return keys for the document
type Database ¶
func (*Database) Collections ¶
Collections returns the list of collections in the database
func (*Database) Delete ¶
func (database *Database) Delete(ctx context.Context, collection any, filter ...*Filter) (int64, error)
Delete a single document from collection and returns the number of deleted documents. If more than one filter expression is provided, they are ANDed together
func (*Database) DeleteMany ¶
func (database *Database) DeleteMany(ctx context.Context, collection any, filter ...*Filter) (int64, error)
DeleteMany deletes zero or more documents from collection and returns the number of deleted documents. If more than one filter expression is provided, they are ANDed together
func (*Database) Find ¶
Find selects a single document in a collection based on filter and sort parameters. If more than one filter expression is provided, they are ANDed together
func (*Database) FindMany ¶
func (database *Database) FindMany(ctx context.Context, collection any, sort *Sort, filter ...*Filter) (*Cursor, error)
FindMany returns in a collection based on filter and sort parameters, and returns an iteratable cursor to the result set. If more than one filter expression is provided, they are ANDed together
func (*Database) Insert ¶
Insert a single document to the database and return key for the document If writable, the document InsertID field is updated
func (*Database) InsertMany ¶
Insert one or more documents to the database and return number of documents matched and modified all the document types must be the same