answerquest , you actually have the ids in the search results. The search method returns you a list of found docs. When you print it out you see the values for the doc. But each doc is a class of type tinydb.database.Document. It has an attr called doc_id.
below is a example as its hard for me to explain. also the bottom of this thread -
https://github.com/msiemens/tinydb/issues/199 might be useful.
Hope it helps
from tinydb import TinyDB, where, __version__ as tdb_version
from faker import Faker
fake = Faker()
Create some dummy people to use...
returns a list of dicts
built up using Faker
'age': fake.random_int(min=18, max=106),
for i in range(0, num_items)
db_fn = 'dummydata.json'
db = TinyDB(db_fn)
data = make_dummy_data()
docs = db.search(where('age') > 50)
if not docs:
print('No docs found, och....')
although doc appears to be a dict, its actually a class -
It subclasses dict, also has a 'doc_id' instance member
The class is defined at the top of the database.py source file
# can uncomment line below to see more detail
# iterate over the docs returned from search
for doc in docs:
print(doc.doc_id, doc['age']) # just print doc_id and age