mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-02-27 12:39:42 +00:00
Put umzug in server/libs and remove unneeded dependencies from it
This commit is contained in:
parent
8a28029809
commit
6fb1202c1c
15 changed files with 808 additions and 526 deletions
31
server/libs/umzug/storage/mongodb.js
Normal file
31
server/libs/umzug/storage/mongodb.js
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.MongoDBStorage = void 0;
|
||||
function isMongoDBCollectionOptions(arg) {
|
||||
return Boolean(arg.collection);
|
||||
}
|
||||
class MongoDBStorage {
|
||||
constructor(options) {
|
||||
var _a, _b;
|
||||
if (!options || (!options.collection && !options.connection)) {
|
||||
throw new Error('MongoDB Connection or Collection required');
|
||||
}
|
||||
this.collection = isMongoDBCollectionOptions(options)
|
||||
? options.collection
|
||||
: options.connection.collection((_a = options.collectionName) !== null && _a !== void 0 ? _a : 'migrations');
|
||||
this.connection = options.connection; // TODO remove this
|
||||
this.collectionName = (_b = options.collectionName) !== null && _b !== void 0 ? _b : 'migrations'; // TODO remove this
|
||||
}
|
||||
async logMigration({ name: migrationName }) {
|
||||
await this.collection.insertOne({ migrationName });
|
||||
}
|
||||
async unlogMigration({ name: migrationName }) {
|
||||
await this.collection.deleteOne({ migrationName });
|
||||
}
|
||||
async executed() {
|
||||
const records = await this.collection.find({}).sort({ migrationName: 1 }).toArray();
|
||||
return records.map(r => r.migrationName);
|
||||
}
|
||||
}
|
||||
exports.MongoDBStorage = MongoDBStorage;
|
||||
//# sourceMappingURL=mongodb.js.map
|
||||
Loading…
Add table
Add a link
Reference in a new issue