mirror of
https://github.com/Tzahi12345/YoutubeDL-Material.git
synced 2026-04-07 00:51:28 +03:00
Fixed bug where notifications wouldn't be set as read if using local db
This commit is contained in:
@@ -720,7 +720,14 @@ exports.updateRecord = async (table, filter_obj, update_obj, nested_mode = false
|
|||||||
exports.updateRecords = async (table, filter_obj, update_obj) => {
|
exports.updateRecords = async (table, filter_obj, update_obj) => {
|
||||||
// local db override
|
// local db override
|
||||||
if (using_local_db) {
|
if (using_local_db) {
|
||||||
exports.applyFilterLocalDB(local_db.get(table), filter_obj, 'filter').assign(update_obj).write();
|
exports.applyFilterLocalDB(local_db.get(table), filter_obj, 'filter').each((record) => {
|
||||||
|
const props_to_update = Object.keys(update_obj);
|
||||||
|
for (let i = 0; i < props_to_update.length; i++) {
|
||||||
|
const prop_to_update = props_to_update[i];
|
||||||
|
const prop_value = update_obj[prop_to_update];
|
||||||
|
record[prop_to_update] = prop_value;
|
||||||
|
}
|
||||||
|
}).write();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -175,6 +175,15 @@ describe('Database', async function() {
|
|||||||
await db_api.removeRecord('test', {test_update: 'test'});
|
await db_api.removeRecord('test', {test_update: 'test'});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('Update records', async function() {
|
||||||
|
await db_api.insertRecordIntoTable('test', {test_update: 'test', key: 'test1'});
|
||||||
|
await db_api.insertRecordIntoTable('test', {test_update: 'test', key: 'test2'});
|
||||||
|
await db_api.updateRecords('test', {test_update: 'test'}, {added_field: true});
|
||||||
|
const updated_records = await db_api.getRecords('test', {added_field: true});
|
||||||
|
assert(updated_records.length === 2);
|
||||||
|
await db_api.removeRecord('test', {test_update: 'test'});
|
||||||
|
});
|
||||||
|
|
||||||
it('Remove property from record', async function() {
|
it('Remove property from record', async function() {
|
||||||
await db_api.insertRecordIntoTable('test', {test_keep: 'test', test_remove: 'test'});
|
await db_api.insertRecordIntoTable('test', {test_keep: 'test', test_remove: 'test'});
|
||||||
await db_api.removePropertyFromRecord('test', {test_keep: 'test'}, {test_remove: true});
|
await db_api.removePropertyFromRecord('test', {test_keep: 'test'}, {test_remove: true});
|
||||||
|
|||||||
Reference in New Issue
Block a user