createOrOpen static method
Implementation
static ZvecCollection createOrOpen({
required String path,
required int dimension,
String name = 'default',
}) {
final collectionDirectory = Directory(path);
if (collectionDirectory.existsSync()) {
final collection = open(path);
final currentDimension = collection.dimension;
if (currentDimension != dimension) {
collection.close();
throw ZvecException(
-1,
'Existing collection dimension is $currentDimension, expected $dimension.',
);
}
return collection;
}
collectionDirectory.parent.createSync(recursive: true);
return create(path: path, dimension: dimension, name: name);
}