-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtinydb-dicas.txt
55 lines (34 loc) · 867 Bytes
/
tinydb-dicas.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
RESUMO - TinyDB
===============
from tinydb import TinyDB, Query, where
db = TinyDB('arquivo.json')
User = Query()
# Dados de exemplo são dicionários com as chaves 'nome' e 'idade'
CRUD
----
db.insert({chave: valor, ...})
db.insert_all([{chave: valor}, ...])
db.update(fields, query)
db.all()
db.search(Query().field > 40)
db.search(Query()['field'] > 40)
db.search(where('field') > 40)
db.search(Query().field.exists())
db.search(Query().field.matches())
db.search(Query().field.search())
db.search(Query().field.test())
db.search(Query().field.any())
db.search(Query().field.all())
db.search(Query().field.one_of())
db.search(Query().field.fragment(dict))
db.upsert()
~ & |
db.remove(query)
db.remove(doc_id=[num])
db.remove(doc_ids=[...])
db.truncate()
db.drop_table('tabela')
db.drop_tables()
len(db)
db.count(query)
db.contains(query)