@ -42,12 +42,12 @@ export class YAMLDatabase implements Database {
return Promise.resolve();
}
public get(table: DatabaseTable, key: string): Promise<DatabaseValue|undefined> {
return Promise.resolve(undefined);
public get(table: DatabaseTable, key: string): Promise<DatabaseValue> {
throw new Error("Key does not exist");
}
public getAll(table: DatabaseTable): Promise<{ [index: string]: DatabaseValue; }> {
return Promise.resolve({});
public getAll(table: DatabaseTable): Promise<DatabaseValue[]> {
return Promise.resolve([]);
}
}
```
@ -205,21 +205,21 @@ exists, it should do nothing and reject.
#### get()
```typescript
function get(table: 'assfiles', key: string): Promise<AssFile|undefined>
function get(table: 'assusers', key: string): Promise<AssUser|undefined>
function get(table: 'asstokens', key: string): Promise<UploadToken|undefined>
function get(table: DatabaseTable, key: string): Promise<DatabaseValue|undefined>
function get(table: 'assfiles', key: string): Promise<AssFile>
function get(table: 'assusers', key: string): Promise<AssUser
function get(table: 'asstokens', key: string): Promise<UploadToken>
function get(table: DatabaseTable, key: string): Promise<DatabaseValue>
```
`get` gets a value from the database. It should resolve to undefined if the key does not exist and should resolve to the value if it does. If something goes wrong it should reject.
`get` gets a value from the database. It should throw an error if the key does not exist and should resolve to the value if it does. If something goes wrong it should reject.
#### getAll()
```typescript
function getAll(table: 'assfiles', key: string): Promise<{ [index: string]: AssFile }>
function getAll(table: 'assusers', key: string): Promise<{ [index: string]: AssUser }>
function getAll(table: 'asstokens', key: string): Promise<{ [index: string]: UploadToken }>
function getAll(table: DatabaseTable, key: string): Promise<{ [index: string]: DatabaseValue }>
function getAll(table: 'assfiles', key: string): Promise<AssFile[]>
function getAll(table: 'assusers', key: string): Promise<AssUser[]>
function getAll(table: 'asstokens', key: string): Promise<UploadToken[]>
function getAll(table: DatabaseTable, key: string): Promise<DatabaseValue[]>
```
`getAll` should resolve to an object containing a map of keys to values. It should reject if something goes wrong.
`getAll` should resolve an array of values. It should reject if something goes wrong.
### Database configuration
When a database is selected, `DBManager` calls `db.open()` to connect