Batch deleteSentProtoRecipient queries
This commit is contained in:
parent
b71e4875e6
commit
6f3191117f
5 changed files with 151 additions and 81 deletions
|
@ -416,6 +416,49 @@ describe('sendLog', () => {
|
|||
assert.lengthOf(await getAllSentProtos(), 0);
|
||||
assert.lengthOf(await _getAllSentProtoRecipients(), 0);
|
||||
});
|
||||
|
||||
it('deletes multiple recipients in a single transaction', async () => {
|
||||
const timestamp = Date.now();
|
||||
|
||||
const recipientUuid1 = getGuid();
|
||||
const recipientUuid2 = getGuid();
|
||||
const proto = {
|
||||
contentHint: 1,
|
||||
proto: Buffer.from(getRandomBytes(128)),
|
||||
timestamp,
|
||||
};
|
||||
await insertSentProto(proto, {
|
||||
messageIds: [getGuid()],
|
||||
recipients: {
|
||||
[recipientUuid1]: [1, 2],
|
||||
[recipientUuid2]: [1],
|
||||
},
|
||||
});
|
||||
|
||||
assert.lengthOf(await getAllSentProtos(), 1);
|
||||
assert.lengthOf(await _getAllSentProtoRecipients(), 3);
|
||||
|
||||
await deleteSentProtoRecipient([
|
||||
{
|
||||
timestamp,
|
||||
recipientUuid: recipientUuid1,
|
||||
deviceId: 1,
|
||||
},
|
||||
{
|
||||
timestamp,
|
||||
recipientUuid: recipientUuid1,
|
||||
deviceId: 2,
|
||||
},
|
||||
{
|
||||
timestamp,
|
||||
recipientUuid: recipientUuid2,
|
||||
deviceId: 1,
|
||||
},
|
||||
]);
|
||||
|
||||
assert.lengthOf(await getAllSentProtos(), 0);
|
||||
assert.lengthOf(await _getAllSentProtoRecipients(), 0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#getSentProtoByRecipient', () => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue