def _add_quote(storage, network, channel, origin, quote): with database.transaction(): quote = Quote.create(by=origin, quote=quote, channel=channel, network=network, ts=datetime.utcnow()) quote.save() with storage.index.writer() as writer: writer.add_document(id=quote.id, by=quote.by, quote=quote.quote, channel=quote.channel, network=quote.network, ts=quote.ts) return quote
def _delete_quote(storage, qid): with database.transaction(): Quote.delete().where(Quote.id == qid).execute() storage.index.delete_by_term("id", qid)