CollectionReference<T extends Object?> constructor
CollectionReference<T extends Object?>(- {required QueryHelper helper,
- required FusabaseOracledb oracledb,
- required String path,
- dynamic parent_}
)
Implementation
CollectionReference(
{required QueryHelper helper,
required FusabaseOracledb oracledb,
required String path,
dynamic parent_})
: _id = "",
super(
helper: helper, oracledb: oracledb, path: path, parent: parent_) {
path = path.toString().trim();
List<String> tokens = path.split('/');
_id = tokens.removeAt(tokens.length - 1);
type = "collection";
// if (_id == "") {
// throw Utils.oracledbErrorHandler(
// 400, OracledbErrorMessages.incorrectDocumentId, null);
// }
if (parent_ != null) {
_parent = parent_;
} else {
if (tokens.isEmpty) {
_parent = null;
} else {
_parent = oracledb.doc(tokens.join('/'));
}
}
_path = (_parent != null) ? [..._parent._path] : [];
_path.add(_id);
if (_path.length % 2 == 0) {
throw Utils.oracledbErrorHandler(
400, OracledbErrorMessages.incorrectCollectionPath, null);
}
if (_parent is CollectionReference) {
throw Utils.oracledbErrorHandler(
400, OracledbErrorMessages.notCollectionReference, null);
}
}