How to use the tinydb.operations.add function in tinydb

To help you get started, we’ve selected a few tinydb examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github msiemens / tinydb / tests / test_operations.py View on Github external
def test_add_int(db):
    db.update(add('int', 5), where('char') == 'a')
    assert db.get(where('char') == 'a')['int'] == 6
github msiemens / tinydb / tests / test_operations.py View on Github external
def test_add_str(db):
    db.update(add('char', 'xyz'), where('char') == 'a')
    assert db.get(where('char') == 'axyz')['int'] == 1
github CentOS-PaaS-SIG / linchpin / linchpin / rundb / tinydb.py View on Github external
# fetch the resources dict, index
            # by filtering them from outputs list
            res_list = [(idx, x) for idx, x in enumerate(tx_rec)
                        if "resources" in x]
            if len(res_list) != 0:
                res_idx = res_list[0][0]
                resources = res_list[0][1]
                if "resources" in list(value[0].keys()):
                    de = resources["resources"]
                    for i in value[0]["resources"]:
                        de.append(i)
                    de = {"resources": de}
                    tx_rec[res_idx] = de
                    res = t.update(tinySet(key, [de]), doc_ids=[run_id])
                    return res
        changed = t.update(add(key, value), doc_ids=[run_id])
        return changed
github ml-hispano / MLH_bot / bots / MsTaco / src / persistence.py View on Github external
def add_tacos(self, amount, bonus=False):
        users_db.update(add('owned_tacos', amount), Query()['user_id'] == self.user_id)
        if bonus:
            users_db.update({'daily_bonus': False}, Query()['user_id'] == self.user_id)
        self.update()
github cea-sec / ivre / ivre / db / tiny.py View on Github external
force=False):
        q = Query()
        flt = []
        if only_if_unassigned:
            flt.append(q.scan == None)  # noqa: E711
        elif not force:
            flt.append(q.scan != False)  # noqa: E712
        if flt:
            flt = self.flt_and(*flt)
        else:
            flt = self.flt_empty
        self.db.update({"scan": scanid}, cond=flt, doc_ids=[agentid])
        agent = self.get_agent(agentid)
        if scanid is not None and scanid is not False \
           and scanid == agent["scan"]:
            self.db_scans.update(add("agents", [agentid]),
                                 cond=~q.agents.any([agentid]),
                                 doc_ids=[scanid])