Introduce note deletion functionality
This commit is contained in:
parent
ed4fec5549
commit
47f9db35bd
@ -1001,6 +1001,13 @@ class AnkiConnect:
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
@api()
|
||||||
|
def deleteNotes(self, notes):
|
||||||
|
try:
|
||||||
|
self.collection().remNotes(notes)
|
||||||
|
finally:
|
||||||
|
self.stopEditing()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
24
README.md
24
README.md
@ -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 ####
|
#### Cards ####
|
||||||
|
|
||||||
* **suspend**
|
* **suspend**
|
||||||
|
@ -84,6 +84,10 @@ class TestNotes(unittest.TestCase):
|
|||||||
noteIds = util.invoke('findNotes', query='deck:test')
|
noteIds = util.invoke('findNotes', query='deck:test')
|
||||||
self.assertEqual(len(noteIds), len(notes) + 1)
|
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__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
Loading…
Reference in New Issue
Block a user