How to use the tinydb.operations.set 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_set(db):
    db.update(set('char', 'xyz'), where('char') == 'a')
    assert db.get(where('char') == 'xyz')['int'] == 1
github wolfg1969 / oh-my-stars / ohmystars / db.py View on Github external
name = repo.get('name')
            language = repo.get('language')
            description = repo.get('description')

            if language:
                for lang in language.split():
                    update_inverted_index(language_docs, lang.lower(), doc_id)

            keywords = split_repo_name(name)
            if description:
                keywords += split_repo_desc(description)
            for keyword in split_keywords(keywords):
                update_inverted_index(keyword_docs, keyword.lower(), doc_id)

        self._idx.update(operations.set('docs', language_docs), Query().name == 'language')
        self._idx.update(operations.set('docs', keyword_docs), Query().name == 'keyword')
github wolfg1969 / oh-my-stars / ohmystars / db.py View on Github external
# update index
            name = repo.get('name')
            language = repo.get('language')
            description = repo.get('description')

            if language:
                for lang in language.split():
                    update_inverted_index(language_docs, lang.lower(), doc_id)

            keywords = split_repo_name(name)
            if description:
                keywords += split_repo_desc(description)
            for keyword in split_keywords(keywords):
                update_inverted_index(keyword_docs, keyword.lower(), doc_id)

        self._idx.update(operations.set('docs', language_docs), Query().name == 'language')
        self._idx.update(operations.set('docs', keyword_docs), Query().name == 'keyword')
github cpssd-students / steely / steely / plugins / gex.py View on Github external
def gex_set_image(user, card_id, card_image_url):
    gex_util.check_for_card(user, card_id)
    CARD_DB.update(operations.set('image', card_image_url), CARD.id == card_id)
github MoritzR / fints2ledger / source / hconverter.py View on Github external
def __init__(self, db):
        self.db = db
        self.markAsClassified = operations.set("classified", True)
github CentOS-PaaS-SIG / linchpin / linchpin / rundb / tinydb.py View on Github external
tx_rec = t.get(doc_id=run_id).get("outputs", [])
        if len(tx_rec) > 0 and isinstance(value, list):
            # 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