DBCollectionFree class abstract
An abstract class representing a MongoDB collection with utility methods.
The DBCollection
class provides an abstraction over a MongoDB collection,
offering various methods to interact with the database, such as checking for
the existence of a document by its ID, updating fields, and more. This class
is meant to be extended by other classes for more specific collection implementations.
Constructors
-
DBCollectionFree.new({required String name, required Db db, required DBFormFree form, Map<
String, DBIndex> indexes = const {}}) -
Constructor to initialize the
name
of the collection and thedb
instance.
Properties
- collection → DbCollection
-
Provides direct access to the underlying MongoDB collection.
no setter
- collectionEvent ↔ CollectionEvent
-
getter/setter pair
- db ↔ Db
-
The MongoDB database instance.
getter/setter pair
- form ↔ DBFormFree
-
getter/setter pair
- hashCode → int
-
The hash code for this object.
no setterinherited
-
indexes
↔ Map<
String, DBIndex> -
getter/setter pair
- name ↔ String
-
The name of the MongoDB collection.
getter/setter pair
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
copy(
String id) → Future< void> - Creates a copy of a document by its ID and inserts it as a new document.
-
delete(
String id) → Future< bool> - Deletes a document from the collection by its ID.
-
deleteOid(
ObjectId oid) → Future< bool> - Deletes a document from the collection by its ID.
-
existId(
String idField) → Future< bool> - Checks if a document with the given ID exists in the collection.
-
existOid(
ObjectId? id) → Future< bool> -
getAll(
{SelectorBuilder? selector, Map< String, Object?> ? filter, FindOptions? findOptions, String? hint, int? skip, Map<String, Object> ? sort, int? limit, Map<String, Object> ? hintDocument, Map<String, Object> ? projection, Map<String, Object> ? rawOptions}) → Future<List< Map< >String, Object?> > -
getById(
String id) → Future< Map< String, Object?> ?> -
getByOid(
ObjectId? oid) → Future< Map< String, Object?> ?> -
getCount(
{String? field, Object? value, Map< String, Object?> ? filter}) → Future<int> -
getSearchableFilter(
{required Map< String, Object?> inputs, String searchFiled = 'search'}) → Map<String, Object?> -
insert(
Map< String, Object?> data) → Future<FormResultFree> -
mergeOne(
String id, Map< String, Object?> data) → Future<FormResultFree?> -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
replaceOne(
String id, Map< String, Object?> data) → Future<FormResultFree?> -
routeDeleteOne(
String path, {required WebRequest rq, List< String> methods = const [RequestMethods.GET], Future<ApiDoc> ? apiDoc()?, WaAuthController? auth, List<String> extraPath = const [], List<String> excludePaths = const [], List<String> hosts = const ['*'], Map<String, Object?> params = const {}, List<String> permissions = const [], List<int> ports = const []}) → WebRoute -
routeGetAll(
String path, {required WebRequest rq, List< String> methods = const [RequestMethods.GET], Future<ApiDoc> ? apiDoc()?, WaAuthController? auth, List<String> extraPath = const [], List<String> excludePaths = const [], List<String> hosts = const ['*'], Map<String, Object?> params = const {}, List<String> permissions = const [], List<int> ports = const [], List<WebRoute> children = const [], bool paging = true, int pageSize = 20, bool orderReverse = true, String orderBy = '_id'}) → WebRoute -
routeGetOne(
String path, {required WebRequest rq, List< String> methods = const [RequestMethods.GET], Future<ApiDoc> ? apiDoc()?, WaAuthController? auth, List<String> extraPath = const [], List<String> excludePaths = const [], List<String> hosts = const ['*'], Map<String, Object?> params = const {}, List<String> permissions = const [], List<int> ports = const []}) → WebRoute -
routeInsert(
String path, {required WebRequest rq, List< String> methods = const [RequestMethods.POST], Future<ApiDoc> ? apiDoc()?, WaAuthController? auth, List<String> extraPath = const [], List<String> excludePaths = const [], List<String> hosts = const ['*'], Map<String, Object?> params = const {}, List<String> permissions = const [], List<int> ports = const []}) → WebRoute -
routes(
String path, {required WebRequest rq, bool useRouteAll = true, bool useRouteDelete = true, bool useRouteInsert = true, bool useRouteUpdate = true, bool useRouteGetOne = true, bool paging = true, int pageSize = 20, bool orderReverse = true, String orderBy = '_id', Future< ApiDoc> ? docAll()?, Future<ApiDoc> ? docDelete()?, Future<ApiDoc> ? docInsert()?, Future<ApiDoc> ? docUpdate()?, Future<ApiDoc> ? docOne()?, List<WebRoute> children = const []}) → List<WebRoute> - Generate list of all routes for an API collection.
-
routeUpdate(
String path, {required WebRequest rq, List< String> methods = const [RequestMethods.POST], Future<ApiDoc> ? apiDoc()?, WaAuthController? auth, List<String> extraPath = const [], List<String> excludePaths = const [], List<String> hosts = const ['*'], Map<String, Object?> params = const {}, List<String> permissions = const [], List<int> ports = const []}) → WebRoute -
toFormResult(
Map< String, Object?> document) → Future<FormResultFree> -
toModel(
Map< String, Object?> document, {List<String> ? selectedFields}) → Future<Map< String, Object?> > -
toString(
) → String -
A string representation of this object.
inherited
-
updateField(
String id, String field, Object? value) → Future< FormResultFree?> - Updates a specific field of a document by its ID.
-
validate(
Map< String, Object?> data, {List<String> onlyCheckKeys = const []}) → Future<FormResultFree>
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
printDesign(
) → void