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
- Python
- TypeScript
- shell
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.
db.labels.find()
// All labels
const { data } = await db.labels.find()
// { MOVIE: 84, ACTOR: 312, DIRECTOR: 47 }
// Labels for records where rating > 8
const { data } = await db.labels.find({
where: { rating: { $gt: 8 } }
})
// { MOVIE: 21 }
find() accepts the same where, skip, limit parameters as db.records.find().
POST /api/v1/labels/search
# All labels
curl -X POST https://api.rushdb.com/api/v1/labels/search \
-H "Authorization: Bearer $RUSHDB_API_KEY" \
-H "Content-Type: application/json" \
-d '{}'
# Labels that have records matching a condition
curl -X POST https://api.rushdb.com/api/v1/labels/search \
-H "Authorization: Bearer $RUSHDB_API_KEY" \
-H "Content-Type: application/json" \
-d '{"where": {"rating": {"$gte": 8}}}'
Response: { [label]: count } map.
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
- Python
- TypeScript
- shell
db.properties.find()
# All properties
props = db.properties.find()
# Filtered by type
props = db.properties.find({
"where": {"type": "string"},
"limit": 20
})
db.properties.find()
const { data } = await db.properties.find({
where: { type: 'number' }
})
// [{ id, name: 'rating', type: 'number', ... }, ...]
POST /api/v1/properties/search
curl -X POST https://api.rushdb.com/api/v1/properties/search \
-H "Authorization: Bearer $RUSHDB_API_KEY" \
-H "Content-Type: application/json" \
-d '{"where": {"type": "string"}}'
Find by ID
- Python
- TypeScript
- shell
db.properties.find_by_id(property_id)
prop = db.properties.find_by_id("prop-123")
db.properties.findById(id)
const prop = await db.properties.findById('property-id')
GET /api/v1/properties/:propertyId
curl https://api.rushdb.com/api/v1/properties/prop-123 \
-H "Authorization: Bearer $RUSHDB_API_KEY"
Get Property Values
Enumerate distinct values for a property — useful for building filter UIs, autocomplete, or feeding into db.ai.get_ontology().
- Python
- TypeScript
- shell
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)
db.properties.values(propertyId, params?)
const { data: genres } = await db.properties.values('prop-id-genre')
// ['sci-fi', 'action', 'drama', ...]
// With filter
const { data } = await db.properties.values('prop-id', {
query: 'sci', // text prefix filter
orderBy: 'asc',
limit: 10
})
POST /api/v1/properties/:propertyId/values
curl -X POST https://api.rushdb.com/api/v1/properties/prop-123/values \
-H "Authorization: Bearer $RUSHDB_API_KEY" \
-H "Content-Type: application/json" \
-d '{"query": "sci", "orderBy": "asc", "limit": 100}'
| Field | Type | Description |
|---|---|---|
query | string | Filter values containing this text |
orderBy | "asc" | "desc" | Sort direction |
skip | number | Pagination offset |
limit | number | Max values to return |
Delete Property
Deletes the property definition and removes it from all records that have it. This is irreversible.
- Python
- TypeScript
- shell
db.properties.delete(property_id)
db.properties.delete("prop-123")
db.properties.delete(id)
await db.properties.delete('property-id')
DELETE /api/v1/properties/:propertyId
curl -X DELETE https://api.rushdb.com/api/v1/properties/prop-123 \
-H "Authorization: Bearer $RUSHDB_API_KEY"
See also
- Discover Your Schema — live ontology via
db.ai.getOntology() - Find & Query — query records by property value
- Where Operators — filter syntax reference