Spaces:
Running
Running
File size: 752 Bytes
b39afbe |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
/**
* Copyright (c) 2023 MERCENARIES.AI PTE. LTD.
* All rights reserved.
*/
import type * as Nano from 'nano';
interface IDBObject {
_id?: string;
_rev?: string;
}
interface IDBObjectLink {
id: string;
type?: string;
name: string;
}
abstract class DBObject implements IDBObject {
_id?: string;
_rev?: string;
id: string;
createdAt: number;
lastUpdated: number;
constructor(id: string) {
this._rev = undefined;
this.id = id;
this.createdAt = Date.now();
this.lastUpdated = Date.now();
}
processAPIResponse(response: Nano.DocumentInsertResponse) {
if (response.ok) {
this._id = response.id;
this._rev = response.rev;
}
}
}
export { type IDBObject, type IDBObjectLink, DBObject };
|