* Get topic data, without content.
* @param {*} dbCtx
* @param {String} topicUrl
+ * @param {Boolean} applyDefaults
*/
- async topicGetByUrl(dbCtx, topicUrl) {
+ async topicGetByUrl(dbCtx, topicUrl, applyDefaults = true) {
this._notImplemented('topicGetByUrl', arguments);
}
}
- async topicGetByUrl(dbCtx, topicUrl) {
+ async topicGetByUrl(dbCtx, topicUrl, applyDefaults = true) {
const _scope = _fileScope('topicGetByUrl');
this.logger.debug(_scope, 'called', { topicUrl });
let topic;
try {
topic = await dbCtx.oneOrNone(this.statement.topicGetByUrl, { topicUrl });
- return this._topicDefaults(topic);
+ if (applyDefaults) {
+ topic = this._topicDefaults(topic);
+ }
+ return topic;
} catch (e) {
this.logger.error(_scope, 'failed', { error: e, topic, topicUrl });
throw e;
}
- topicGetByUrl(dbCtx, topicUrl) {
+ topicGetByUrl(dbCtx, topicUrl, applyDefaults = true) {
const _scope = _fileScope('topicGetByUrl');
this.logger.debug(_scope, 'called', { topicUrl });
try {
topic = this.statement.topicGetByUrl.get({ topicUrl });
DatabaseSQLite._topicDataToNative(topic);
- return this._topicDefaults(topic);
+ if (applyDefaults) {
+ topic = this._topicDefaults(topic);
+ }
+ return topic;
} catch (e) {
this.logger.error(_scope, 'failed', { error: e, topic, topicUrl });
throw e;
const data = {
topicId,
leaseSecondsMin: 60,
- }
+ };
await db.context(async(dbCtx) => {
- let topic = await db.topicGetByUrl(dbCtx, testData.topicSet.url);
+ const expected = await db.topicGetByUrl(dbCtx, testData.topicSet.url, true);
+ expected.leaseSecondsMin = data.leaseSecondsMin;
+ let topic = await db.topicGetByUrl(dbCtx, testData.topicSet.url, false);
await db.topicUpdate(dbCtx, { ...topic, ...data });
topic = await db.topicGetByUrl(dbCtx, testData.topicSet.url);
assert.strictEqual(Number(topic.leaseSecondsMin), data.leaseSecondsMin);
+ assert.deepEqual(topic, expected);
});
});
step('gets topic by id', async function () {