alks
Version:
CLI for working with ALKS
23 lines (19 loc) • 592 B
text/typescript
import { Key } from '../model/keys';
import { getDb } from './db';
export async function getKeysCollection(): Promise<Collection<Key>> {
const db = await getDb();
return new Promise((resolve, reject) => {
// have the DB load from disk
db.loadDatabase({}, (err?: Error) => {
if (err) {
reject(err);
return;
}
// grab the keys collection (if its null this is a new run, create the collection)
const keys =
db.getCollection('keys') ||
db.addCollection('keys', { indices: ['expires'] });
resolve(keys);
});
});
}