Documentation ¶
Overview ¶
Package simplenosqldb implements an in-memory NoSQLDB that supports a subset of MongoDB's query and update API.
Only a small set of common basic filter and update operators are supported, but typically this is sufficient for most applications and enables writing service-level unit tests.
Index ¶
- func SetVerbose(enabled bool) bool
- type SimpleCollection
- func (db *SimpleCollection) DeleteMany(ctx context.Context, filter bson.D) error
- func (db *SimpleCollection) DeleteOne(ctx context.Context, filter bson.D) error
- func (db *SimpleCollection) FindMany(ctx context.Context, filter bson.D, projection ...bson.D) (backend.NoSQLCursor, error)
- func (db *SimpleCollection) FindOne(ctx context.Context, filter bson.D, projection ...bson.D) (backend.NoSQLCursor, error)
- func (db *SimpleCollection) InsertMany(ctx context.Context, documents []interface{}) error
- func (db *SimpleCollection) InsertOne(ctx context.Context, document interface{}) error
- func (db *SimpleCollection) ReplaceMany(ctx context.Context, filter bson.D, replacements ...interface{}) (int, error)
- func (db *SimpleCollection) ReplaceOne(ctx context.Context, filter bson.D, replacement interface{}) (int, error)
- func (db *SimpleCollection) String() string
- func (db *SimpleCollection) UpdateMany(ctx context.Context, filter bson.D, update bson.D) (int, error)
- func (db *SimpleCollection) UpdateOne(ctx context.Context, filter bson.D, update bson.D) (int, error)
- func (db *SimpleCollection) Upsert(ctx context.Context, filter bson.D, document interface{}) (bool, error)
- func (db *SimpleCollection) UpsertID(ctx context.Context, id primitive.ObjectID, document interface{}) (bool, error)
- type SimpleCursor
- type SimpleNoSQLDB
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SetVerbose ¶
Enable or disable verbose logging; used for testing
Types ¶
type SimpleCollection ¶
type SimpleCollection struct {
// contains filtered or unexported fields
}
Simple implementations of the NoSQLDB Interfaces from runtime/core/backend
func (*SimpleCollection) DeleteMany ¶
func (*SimpleCollection) FindMany ¶
func (db *SimpleCollection) FindMany(ctx context.Context, filter bson.D, projection ...bson.D) (backend.NoSQLCursor, error)
func (*SimpleCollection) FindOne ¶
func (db *SimpleCollection) FindOne(ctx context.Context, filter bson.D, projection ...bson.D) (backend.NoSQLCursor, error)
func (*SimpleCollection) InsertMany ¶
func (db *SimpleCollection) InsertMany(ctx context.Context, documents []interface{}) error
func (*SimpleCollection) InsertOne ¶
func (db *SimpleCollection) InsertOne(ctx context.Context, document interface{}) error
func (*SimpleCollection) ReplaceMany ¶
func (*SimpleCollection) ReplaceOne ¶
func (*SimpleCollection) String ¶
func (db *SimpleCollection) String() string
func (*SimpleCollection) UpdateMany ¶
type SimpleCursor ¶
type SimpleCursor struct {
// contains filtered or unexported fields
}
Simple implementations of the NoSQLDB Interfaces from runtime/core/backend
type SimpleNoSQLDB ¶
type SimpleNoSQLDB struct {
// contains filtered or unexported fields
}
Implements the backend.NoSQLDatabase interface for a subset of MongoDB's query and update operators.
Only a small set of common basic filter and update operators are supported, but typically this is sufficient for most applications and enables writing service-level unit tests.
func NewSimpleNoSQLDB ¶
func NewSimpleNoSQLDB(ctx context.Context) (*SimpleNoSQLDB, error)
Instantiate a new in-memory NoSQLDB
func (*SimpleNoSQLDB) GetCollection ¶
func (impl *SimpleNoSQLDB) GetCollection(ctx context.Context, db_name string, collection_name string) (backend.NoSQLCollection, error)