Update Getting Started guide, note WIP docs

This commit is contained in:
Andrew Brookins 2021-11-02 14:17:49 -07:00
parent 8a5db647da
commit 8df968542a
14 changed files with 785 additions and 277 deletions

View file

@ -1,5 +1,7 @@
# Embedded Models
**NOTE:** This documentation is a stub, using the same embedded JSON model example as the README.
Redis OM can store and query **nested models** like any document database, with the speed and power you get from Redis. Let's see how this works.
In the next example, we'll define a new `Address` model and embed it within the `Customer` model.
@ -12,6 +14,7 @@ from redis_om.model import (
EmbeddedJsonModel,
JsonModel,
Field,
Migrator
)
class Address(EmbeddedJsonModel):
@ -34,11 +37,15 @@ class Customer(JsonModel):
# Creates an embedded model.
address: Address
```
With these two models and a Redis deployment with the RedisJSON module installed, we can run queries like the following:
# With these two models and a Redis deployment with the RedisJSON
# module installed, we can run queries like the following.
# Before running queries, we need to run migrations to set up the
# indexes that Redis OM will use. You can also use the `migrate`
# CLI tool for this!
Migrator().run()
```python
# Find all customers who live in San Antonio, TX
Customer.find(Customer.address.city == "San Antonio",
Customer.address.state == "TX")