Documentation
¶
Index ¶
- Constants
- func CreateWhereClause(filter types.Document) (sql string, err error)
- func GetUpdateValue(value any) (updateValue string, err error)
- func Ignored(doc *types.Document, l *zap.Logger, fields ...string)
- func IsIdUnique(id any, db, collection string, ctx context.Context, hanapool *hana.Hpool) (unique bool, errMsg error, err error)
- func NewError(code ErrorCode, err error) error
- func NewErrorMessage(code ErrorCode, msg string, args ...any) error
- func NoError(err error)
- func NotFail[T any](res T, err error) T
- func PrepareArrayForSQL(a *types.Array) (sqlArray string, err error)
- func ProjectDocuments(docs *types.Array, projection types.Document) (err error)
- func Projection(projection types.Document) (sql string, exclusion bool, err error)
- func Unimplemented(doc *types.Document, fields ...string) error
- func Update(updateDoc types.Document) (updateSQL string, notWhereSQL string, err error)
- func Upsert(updateDoc *types.Document, filter *types.Document, replace bool) (*types.Document, error)
- type Error
- type ErrorCode
- type Storage
Constants ¶
const ( ErrBadValue = ErrorCode(2) // BadValue ErrNamespaceNotFound = ErrorCode(26) // NamespaceNotFound ErrNamespaceExists = ErrorCode(48) // NamespaceExists ErrCommandNotFound = ErrorCode(59) // CommandNotFound ErrNotImplemented = ErrorCode(238) // NotImplemented ErrSortBadValue = ErrorCode(15974) // SortBadValue ErrProjectionInEx = ErrorCode(31253) // Location31253 ErrProjectionExIn = ErrorCode(31254) // Location31254 ErrRegexOptions = ErrorCode(51075) // Location51075 )
for complete list of MongoDB error codes see: https://github.com/mongodb/mongo/blob/master/src/mongo/base/error_codes.yml
Variables ¶
This section is empty.
Functions ¶
func CreateWhereClause ¶
CreateWhereClause creates the WHERE-clause of the SQL statement.
func GetUpdateValue ¶
getUpdateValue prepares the value for SQL statement.
func IsIdUnique ¶
func IsIdUnique(id any, db, collection string, ctx context.Context, hanapool *hana.Hpool) (unique bool, errMsg error, err error)
IsIdUnique will check if _id for a document is unique before insertion. - err is an error thrown by a function used. - errMsg is the error message used if id is not unique.
func NewErrorMessage ¶
NewErrorMessage creates a new wire protocol error with message.
Code can't be zero, message can't be empty.
func PrepareArrayForSQL ¶
PrepareArrayForSQL prepares an array which is inside of a document for SQL.
func ProjectDocuments ¶
ProjectDocuments will be used if it is an exclusion to performs the exclusion on each document together with the function projectDocument.
func Projection ¶
Projection checks if projection is an inclusion or exclusion. If inclusion then the sql needed to perform inclusion is created. If exclusion then the removal of fields will first happen after retrieval of documents.
func Unimplemented ¶
Unimplemented returns ErrNotImplemented if doc has any of the given fields.
Types ¶
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
Error represents wire protocol error.
func ProtocolError ¶
ProtocolError converts any error to wire protocol error.
Nil panics, *Error (possibly wrapped) is returned unwrapped with true, any other value is wrapped with InternalError and returned with false.
type Storage ¶
type Storage interface {
MsgCreateIndexes(context.Context, *wire.OpMsg) (*wire.OpMsg, error)
MsgDelete(context.Context, *wire.OpMsg) (*wire.OpMsg, error)
MsgFindOrCount(context.Context, *wire.OpMsg) (*wire.OpMsg, error)
MsgFindAndModify(context.Context, *wire.OpMsg) (*wire.OpMsg, error)
MsgInsert(context.Context, *wire.OpMsg) (*wire.OpMsg, error)
MsgUpdate(context.Context, *wire.OpMsg) (*wire.OpMsg, error)
}