Introduce note deletion functionality

This commit is contained in:
Mikhail Pontus 2019-02-26 20:28:36 +03:00
parent ed4fec5549
commit 47f9db35bd
3 changed files with 35 additions and 0 deletions

View File

@ -1001,6 +1001,13 @@ class AnkiConnect:
return result
@api()
def deleteNotes(self, notes):
try:
self.collection().remNotes(notes)
finally:
self.stopEditing()

View File

@ -1018,6 +1018,30 @@ guarantee that your application continues to function properly in the future.
```
* **deleteNotes**
Deletes notes with the given ids. If a note has several cards associated with it, all associated cards will be deleted.
*Sample request*:
```json
{
"action": "deleteNotes",
"version": 6,
"params": {
"notes": [1502298033753]
}
}
```
*Sample result*:
```json
{
"result": null,
"error": null
}
```
#### Cards ####
* **suspend**

View File

@ -84,6 +84,10 @@ class TestNotes(unittest.TestCase):
noteIds = util.invoke('findNotes', query='deck:test')
self.assertEqual(len(noteIds), len(notes) + 1)
# deleteNotes
util.invoke('deleteNotes', notes=noteIds)
noteIds = util.invoke('findNotes', query='deck:test')
self.assertEqual(len(noteIds), 0)
if __name__ == '__main__':
unittest.main()