NitriteCollection class abstract

Represents a named document collection stored in Nitrite database. It persists documents into the database. Each document is associated with a unique NitriteId in a collection.

A nitrite collection supports indexing. Every nitrite collection is also observable. It's possible to register a CollectionEventListener to a collection and listen to the changes happening to the collection.

Create a collection

var db = Nitrite().builder()
   .openOrCreate("user", "password");

var collection = db.getCollection("products");
Inheritance

Constructors

NitriteCollection()

Properties

hashCode int
The hash code for this object.
no setterinherited
isDropped bool
Returns true if the collection is dropped; otherwise, false.
no setterinherited
isOpen bool
Returns true if the collection is open; otherwise, false.
no setterinherited
name String
Returns the name of the NitriteCollection.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
size Future<int>
Returns the size of the PersistentCollection.
no setterinherited

Methods

addProcessor(Processor processor) → void
Adds a data processor to this collection.
inherited
clear() Future<void>
Removes all element from the collection.
inherited
close() Future<void>
Closes this PersistentCollection.
inherited
createIndex(List<String> fields, [IndexOptions? indexOptions]) Future<void>
Creates an index on the fields, if not already exists. If indexOptions is null, it will use default options.
inherited
drop() Future<void>
Drops the collection and all of its indices.
inherited
dropAllIndices() Future<void>
Drops all indices from the collection.
inherited
dropIndex(List<String> fields) Future<void>
Drops the index on the fields.
inherited
find({Filter? filter, FindOptions? findOptions}) DocumentCursor
Applies a filter on the collection and returns a customized cursor to the selected documents.
getAttributes() Future<Attributes>
inherited
getById(NitriteId id) Future<Document?>
Gets a single element from the collection by its id. If no element is found, it will return Future<null>.
getStore<Config extends StoreConfig>() NitriteStore<Config>
Returns the NitriteStore instance for this collection.
inherited
hasIndex(List<String> fields) Future<bool>
Checks if the fields is already indexed or not.
inherited
initialize() Future<void>
inherited
insert(Document documents) Future<WriteResult>
Insert a document into a collection. If the document contains a _id value, then the value will be used as a unique key to identify the document in the collection. If the document does not contain any _id value, then nitrite will generate a new NitriteId and will add it to the document.
insertMany(List<Document> documents) Future<WriteResult>
Insert documents into a collection. If the documents contains a _id value, then the value will be used as a unique key to identify each document in the collection. If any document does not contain any _id value, then nitrite will generate a new NitriteId and will add it to the document.
isIndexing(List<String> fields) Future<bool>
Checks if indexing operation is currently ongoing for the fields.
inherited
listIndexes() Future<Iterable<IndexDescriptor>>
Gets a set of all indices in the collection.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
rebuildIndex(List<String> fields) Future<void>
Rebuilds index on the fields if it exists.
inherited
remove(Filter filter, {bool justOne = false}) Future<WriteResult>
Removes matching documents from the collection.
removeOne(Document document) Future<WriteResult>
Removes the document from the collection.
setAttributes(Attributes attributes) Future<void>
inherited
subscribe<T>(CollectionEventListener<T> listener) → void
inherited
toString() String
A string representation of this object.
inherited
unsubscribe<T>(CollectionEventListener<T> listener) → void
inherited
update(Filter filter, Document update, [UpdateOptions? updateOptions]) Future<WriteResult>
Update the filtered documents in the collection with the update.
updateOne(Document document, {bool insertIfAbsent = false}) Future<WriteResult>
Update a single document in the collection. If insertIfAbsent is true, then this operation will insert the document if it does not exist in the collection.

Operators

operator ==(Object other) bool
The equality operator.
inherited