createWorkDb function
Creates a WorkDB instance using configuration.
This is a convenience function for creating database instances using the WorkDbConfig class.
Example:
final db = createWorkDb(WorkDbConfig(
platform: PlatformType.io,
dataPath: './data',
));
Implementation
ClientWorkDb createWorkDb(WorkDbConfig config) {
final factory = WorkDbFactory();
switch (config.platform) {
case PlatformType.io:
return factory.create(IoWorkDbFactoryInput(
dataPath: config.dataPath,
maxRecordsPerCollection: config.maxRecordsPerCollection,
));
case PlatformType.web:
return factory.create(WebWorkDbFactoryInput(
webStorage: config.webStorage,
maxRecordsPerCollection: config.maxRecordsPerCollection,
));
case PlatformType.memory:
return factory.create(MemoryWorkDbFactoryInput(
maxRecordsPerCollection: config.maxRecordsPerCollection,
));
}
}