Documentation ¶
Overview ¶
Copyright 2023 Codenotary Inc. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2023 Codenotary Inc. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2023 Codenotary Inc. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2023 Codenotary Inc. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2023 Codenotary Inc. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2023 Codenotary Inc. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Constants
- Variables
- type DocumentID
- type DocumentReader
- type EncodedDocument
- type Engine
- func (e *Engine) AddField(ctx context.Context, username, collectionName string, field *protomodel.Field) error
- func (e *Engine) AuditDocument(ctx context.Context, collectionName string, docID DocumentID, desc bool, ...) ([]*protomodel.DocumentAtRevision, error)
- func (e *Engine) CopyCatalogToTx(ctx context.Context, tx *store.OngoingTx) error
- func (e *Engine) CountDocuments(ctx context.Context, query *protomodel.Query, offset int64) (int64, error)
- func (e *Engine) CreateCollection(ctx context.Context, username, name, documentIdFieldName string, ...) error
- func (e *Engine) CreateIndex(ctx context.Context, username, collectionName string, fields []string, ...) error
- func (e *Engine) DeleteCollection(ctx context.Context, username, collectionName string) error
- func (e *Engine) DeleteDocuments(ctx context.Context, username string, query *protomodel.Query) error
- func (e *Engine) DeleteIndex(ctx context.Context, username, collectionName string, fields []string) error
- func (e *Engine) GetCollection(ctx context.Context, collectionName string) (*protomodel.Collection, error)
- func (e *Engine) GetCollections(ctx context.Context) ([]*protomodel.Collection, error)
- func (e *Engine) GetDocuments(ctx context.Context, query *protomodel.Query, offset int64) (DocumentReader, error)
- func (e *Engine) GetEncodedDocument(ctx context.Context, collectionName string, docID DocumentID, txID uint64) (collectionID uint32, documentIdFieldName string, encodedDoc *EncodedDocument, ...)
- func (e *Engine) InsertDocument(ctx context.Context, username, collectionName string, doc *structpb.Struct) (txID uint64, docID DocumentID, err error)
- func (e *Engine) InsertDocuments(ctx context.Context, username, collectionName string, docs []*structpb.Struct) (txID uint64, docIDs []DocumentID, err error)
- func (e *Engine) RemoveField(ctx context.Context, username, collectionName string, fieldName string) error
- func (e *Engine) ReplaceDocuments(ctx context.Context, username string, query *protomodel.Query, ...) (revisions []*protomodel.DocumentAtRevision, err error)
- func (e *Engine) UpdateCollection(ctx context.Context, username, collectionName string, ...) error
- type Options
Constants ¶
const ( DefaultDocumentIDField = "_id" DocumentBLOBField = "_doc" )
const DefaultDocumentMaxNestedFields = 3
const GeneratedDocIDLength = 16
GeneratedDocIDLength is the length of a DocumentID.
const MaxDocumentIDLength = 32
Variables ¶
var ( ErrIllegalArguments = store.ErrIllegalArguments ErrUnsupportedType = errors.New("unsupported type") ErrUnexpectedValue = errors.New("unexpected value") ErrCollectionAlreadyExists = errors.New("collection already exists") ErrCollectionDoesNotExist = errors.New("collection does not exist") ErrMaxLengthExceeded = errors.New("max length exceeded") ErrMultipleDocumentsFound = errors.New("multiple documents found") ErrDocumentNotFound = errors.New("document not found") ErrNoMoreDocuments = errors.New("no more documents") ErrFieldAlreadyExists = errors.New("field already exists") ErrFieldDoesNotExist = errors.New("field does not exist") ErrReservedName = errors.New("reserved name") ErrLimitedIndexCreation = errors.New("unique index creation is only supported on empty collections") ErrConflict = errors.New("conflict due to uniqueness contraint violation or read document was updated by another transaction") )
Functions ¶
This section is empty.
Types ¶
type DocumentID ¶
type DocumentID []byte
DocumentID is an identifier that is automatically generated by the server upon document insertion if not provided.
func NewDocumentIDFromHexEncodedString ¶
func NewDocumentIDFromHexEncodedString(hexEncodedDocID string) (DocumentID, error)
NewDocumentIDFromHexEncodedString returns a DocumentID from a hex string.
func NewDocumentIDFromRawBytes ¶
func NewDocumentIDFromRawBytes(b []byte) (DocumentID, error)
NewDocumentIDFromRawBytes generates a new DocumentID from a byte slice.
func NewDocumentIDFromTimestamp ¶
func NewDocumentIDFromTimestamp(timestamp time.Time, txID uint64) DocumentID
NewDocumentIDFromTimestamp generates a new DocumentID from a timestamp.
func NewDocumentIDFromTx ¶
func NewDocumentIDFromTx(txID uint64) DocumentID
NewDocumentIDFromTx generates a new DocumentID.
func (DocumentID) EncodeToHexString ¶
func (id DocumentID) EncodeToHexString() string
EncodeToHexString returns the hex representation of the DocumentID.
func (DocumentID) Timestamp ¶
func (id DocumentID) Timestamp() time.Time
Timestamp returns the timestamp portion of the DocumentID.
type DocumentReader ¶
type DocumentReader interface { // Read reads a single message from a reader and returns it as a Struct message. Read(ctx context.Context) (*protomodel.DocumentAtRevision, error) // ReadN reads n number of messages from a reader and returns them as a slice of Struct messages. ReadN(ctx context.Context, count int) ([]*protomodel.DocumentAtRevision, error) Close() error }
type EncodedDocument ¶
type EncodedDocument struct { TxID uint64 Revision uint64 // revision is only set when txID == 0 and info is fetch from the index KVMetadata *store.KVMetadata EncodedDocument []byte }
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
func (*Engine) AuditDocument ¶
func (e *Engine) AuditDocument(ctx context.Context, collectionName string, docID DocumentID, desc bool, offset uint64, limit int, includePayload bool) ([]*protomodel.DocumentAtRevision, error)
AuditDocument returns the audit history of a document.
func (*Engine) CopyCatalogToTx ¶
CopyCatalogToTx copies the current sql catalog to the ongoing transaction.
func (*Engine) CountDocuments ¶
func (*Engine) CreateCollection ¶
func (e *Engine) CreateCollection(ctx context.Context, username, name, documentIdFieldName string, fields []*protomodel.Field, indexes []*protomodel.Index) error
func (*Engine) CreateIndex ¶
func (*Engine) DeleteCollection ¶
DeleteCollection deletes a collection.
func (*Engine) DeleteDocuments ¶
func (e *Engine) DeleteDocuments(ctx context.Context, username string, query *protomodel.Query) error
DeleteDocuments deletes documents matching the query
func (*Engine) DeleteIndex ¶
func (*Engine) GetCollection ¶
func (e *Engine) GetCollection(ctx context.Context, collectionName string) (*protomodel.Collection, error)
func (*Engine) GetCollections ¶
func (e *Engine) GetCollections(ctx context.Context) ([]*protomodel.Collection, error)
func (*Engine) GetDocuments ¶
func (e *Engine) GetDocuments(ctx context.Context, query *protomodel.Query, offset int64) (DocumentReader, error)
func (*Engine) GetEncodedDocument ¶
func (e *Engine) GetEncodedDocument(ctx context.Context, collectionName string, docID DocumentID, txID uint64) (collectionID uint32, documentIdFieldName string, encodedDoc *EncodedDocument, err error)
func (*Engine) InsertDocument ¶
func (*Engine) InsertDocuments ¶
func (*Engine) RemoveField ¶
func (*Engine) ReplaceDocuments ¶
func (e *Engine) ReplaceDocuments(ctx context.Context, username string, query *protomodel.Query, doc *structpb.Struct) (revisions []*protomodel.DocumentAtRevision, err error)
type Options ¶
type Options struct {
// contains filtered or unexported fields
}
func DefaultOptions ¶
func DefaultOptions() *Options