Add deleteDecks function
This commit is contained in:
parent
6da8481b07
commit
99d70cc2a4
@ -568,6 +568,14 @@ class AnkiBridge:
|
||||
self.stopEditing()
|
||||
|
||||
|
||||
def deleteDecks(self, decks, cardsToo=False):
|
||||
self.startEditing()
|
||||
for deck in decks:
|
||||
id = self.collection().decks.id(deck)
|
||||
self.collection().decks.rem(id, cardsToo)
|
||||
self.stopEditing()
|
||||
|
||||
|
||||
def cardsToNotes(self, cards):
|
||||
return self.collection().db.list('select distinct nid from cards where id in ' + anki.utils.ids2str(cards))
|
||||
|
||||
@ -861,6 +869,11 @@ class AnkiConnect:
|
||||
return self.anki.changeDeck(cards, deck)
|
||||
|
||||
|
||||
@webApi
|
||||
def deleteDecks(self, decks, cardsToo=False):
|
||||
return self.anki.deleteDecks(decks, cardsToo)
|
||||
|
||||
|
||||
@webApi
|
||||
def cardsToNotes(self, cards):
|
||||
return self.anki.cardsToNotes(cards)
|
||||
|
21
README.md
21
README.md
@ -554,6 +554,27 @@ Below is a list of currently supported actions. Requests with invalid actions or
|
||||
```
|
||||
null
|
||||
```
|
||||
|
||||
* **deleteDecks**
|
||||
|
||||
Deletes decks with the given names. If `cardsToo` is `true` (defaults to `false` if unspecified), the cards within
|
||||
the deleted decks will also be deleted; otherwise they will be moved to the default deck.
|
||||
|
||||
*Sample request*:
|
||||
```
|
||||
{
|
||||
"action": "deleteDecks",
|
||||
"params": {
|
||||
"decks": ["Japanese::JLPT N5", "Easy Spanish"],
|
||||
"cardsToo": true
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
*Sample response*:
|
||||
```
|
||||
null
|
||||
```
|
||||
|
||||
* **cardsToNotes**
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user