DBCollectionFree constructor

DBCollectionFree({
  1. required String name,
  2. required Db db,
  3. required DBFormFree form,
})

Constructor to initialize the name of the collection and the db instance.

When initialized, the constructor checks if the collection exists in the database, and creates it if it does not already exist.

Implementation

DBCollectionFree({required this.name, required this.db, required this.form}) {
  db.getCollectionNames().then((coll) async {
    if (!coll.contains(name)) {
      await db.createCollection(name);
    }
  });
}