3 const common
= require('../common');
4 const DBErrors
= require('./errors');
6 const _fileScope
= common
.fileScope(__filename
);
13 static _camelfy(snakeCase
, delim
= '_') {
14 if (!snakeCase
|| typeof snakeCase
.split
!== 'function') {
17 const words
= snakeCase
.split(delim
);
20 ...words
.map((word
) => word
.charAt(0).toUpperCase() + word
.slice(1)),
24 _notImplemented(method
, args
) {
25 const _scope
= _fileScope(method
);
26 this.logger
.error(_scope
, 'abstract method called', Array
.from(args
));
27 throw new DBErrors
.NotImplemented();
31 this._notImplemented('context', { fn
});
34 async
transaction(dbCtx
, fn
) {
35 this._notImplemented('transaction', { dbCtx
, fn
});
38 async
getAuthById(dbCtx
, id
) {
39 this._notImplemented('getAuthById', { dbCtx
, id
});
42 async
insertLink(dbCtx
, id
, url
, authToken
) {
43 this._notImplemented('insertLink', { dbCtx
, id
, url
, authToken
});
46 async
getLinkById(dbCtx
, id
) {
47 this._notImplemented('getLinkById', { dbCtx
, id
});
50 async
getLinkByUrl(dbCtx
, url
) {
51 this._notImplemented('getLinkByUrl', { dbCtx
, url
});
54 async
accessLink(dbCtx
, id
) {
55 this._notImplemented('accessLink', { dbCtx
, id
});
58 async
expireLink(dbCtx
, id
, expires
) {
59 this._notImplemented('expireLink', { dbCtx
, id
, expires
});
62 async
updateLink(dbCtx
, id
, url
) {
63 this._notImplemented('updateLink', { dbCtx
, id
, url
});
66 async
getAllLinks(dbCtx
) {
67 this._notImplemented('getAllLinks', { dbCtx
});
72 module
.exports
= BaseDatabase
;