@rdfc/sds-storage-writer-ts
Version:
An RDF-Connect processor to write SDS streams into a given storage system
16 lines (15 loc) • 619 B
JavaScript
import { env } from "process";
import { MongoDBRepository } from "./MongoDBRepository.js";
import { RedisRepository } from "./RedisRepository.js";
export function getRepository(dbConfig) {
const url = dbConfig.url || env.DB_CONN_STRING || "mongodb://localhost:27017/ldes";
if (url.startsWith("mongodb")) {
return new MongoDBRepository(url, dbConfig.metadata, dbConfig.data, dbConfig.index);
}
else if (url.startsWith("redis")) {
return new RedisRepository(url, dbConfig.metadata, dbConfig.data, dbConfig.index);
}
else {
throw new Error("Unknown database type");
}
}