Skip to main content

Labels & Properties

RushDB is schema-free — labels and properties emerge automatically as you write records. These APIs let you inspect, enumerate, and manage your schema at runtime.


Labels

A label is a string tag applied to every record (e.g. "Movie", "User", "Order"). The labels API lets you discover which labels exist and how many records each has.

Find Labels

db.labels.find()

# All labels and their record counts
result = db.labels.find({})
# → [LabelResult(name='MOVIE', count=3), LabelResult(name='ACTOR', count=3), ...]

# Labels that have records matching a condition
result = db.labels.find({"where": {"rating": {"$gte": 8}}})
# → [LabelResult(name='MOVIE', count=1)]

db.labels.find() accepts a standard where clause. It returns all labels that have at least one record matching the condition.


Properties

A property is a field definition created automatically when you write a record with a new key. The properties API lets you inspect types, enumerate distinct values, and delete fields.

Find Properties

db.properties.find()

# All properties
props = db.properties.find()

# Filtered by type
props = db.properties.find({
"where": {"type": "string"},
"limit": 20
})

Find by ID

db.properties.find_by_id(property_id)

prop = db.properties.find_by_id("prop-123")

Get Property Values

Enumerate distinct values for a property — useful for building filter UIs, autocomplete, or feeding into db.ai.get_ontology().

db.properties.values(property_id, search_query?)

values_data = db.properties.values(
property_id="prop-123",
search_query={
"query": "sci", # filter values containing this text
"orderBy": "asc",
"limit": 100
}
)

print(values_data.get("values")) # list of distinct values
print(values_data.get("min")) # numeric min (number/datetime props)
print(values_data.get("max")) # numeric max (number/datetime props)

Delete Property

warning

Deletes the property definition and removes it from all records that have it. This is irreversible.

db.properties.delete(property_id)

db.properties.delete("prop-123")

See also