Merge pull request #110 from mpontus/feature/note-deletion

Introduce note deletion functionality
This commit is contained in:
Alex Yatskov 2019-02-27 09:14:43 -08:00 committed by GitHub
commit 399d1db48e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 35 additions and 0 deletions

View File

@ -1001,6 +1001,13 @@ class AnkiConnect:
return result 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 #### #### Cards ####
* **suspend** * **suspend**

View File

@ -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()