document

package
v1.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 20, 2023 License: Apache-2.0 Imports: 17 Imported by: 0

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

View Source
const (
	DefaultDocumentIDField = "_id"
	DocumentBLOBField      = "_doc"
)
View Source
const DefaultDocumentMaxNestedFields = 3
View Source
const GeneratedDocIDLength = 16

GeneratedDocIDLength is the length of a DocumentID.

View Source
const MaxDocumentIDLength = 32

Variables

View Source
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("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 NewEngine

func NewEngine(store *store.ImmuStore, opts *Options) (*Engine, error)

func (*Engine) AuditDocument

func (e *Engine) AuditDocument(ctx context.Context, collectionName string, docID DocumentID, desc bool, offset uint64, limit int) ([]*protomodel.DocumentAtRevision, error)

AuditDocument returns the audit history of a document.

func (*Engine) CopyCatalogToTx

func (e *Engine) CopyCatalogToTx(ctx context.Context, tx *store.OngoingTx) error

CopyCatalogToTx copies the current sql catalog to the ongoing transaction.

func (*Engine) CountDocuments

func (e *Engine) CountDocuments(ctx context.Context, query *protomodel.Query, offset int64) (int64, error)

func (*Engine) CreateCollection

func (e *Engine) CreateCollection(ctx context.Context, name, documentIdFieldName string, fields []*protomodel.Field, indexes []*protomodel.Index) error

func (*Engine) CreateIndex

func (e *Engine) CreateIndex(ctx context.Context, collectionName string, fields []string, isUnique bool) error

func (*Engine) DeleteCollection

func (e *Engine) DeleteCollection(ctx context.Context, collectionName string) error

DeleteCollection deletes a collection.

func (*Engine) DeleteDocuments

func (e *Engine) DeleteDocuments(ctx context.Context, query *protomodel.Query) error

DeleteDocuments deletes documents matching the query

func (*Engine) DeleteIndex

func (e *Engine) DeleteIndex(ctx context.Context, collectionName string, fields []string) error

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 (e *Engine) InsertDocument(ctx context.Context, collectionName string, doc *structpb.Struct) (txID uint64, docID DocumentID, err error)

func (*Engine) InsertDocuments

func (e *Engine) InsertDocuments(ctx context.Context, collectionName string, docs []*structpb.Struct) (txID uint64, docIDs []DocumentID, err error)

func (*Engine) ReplaceDocuments

func (e *Engine) ReplaceDocuments(ctx context.Context, query *protomodel.Query, doc *structpb.Struct) (revisions []*protomodel.DocumentAtRevision, err error)

func (*Engine) UpdateCollection

func (e *Engine) UpdateCollection(ctx context.Context, collectionName string, documentIdFieldName string) error

type Options

type Options struct {
	// contains filtered or unexported fields
}

func DefaultOptions

func DefaultOptions() *Options

func (*Options) Validate

func (opts *Options) Validate() error

func (*Options) WithMaxNestedFields

func (opts *Options) WithMaxNestedFields(maxNestedFields int) *Options

func (*Options) WithPrefix

func (opts *Options) WithPrefix(prefix []byte) *Options

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL