Defining schema
In this document, you’ll learn how to define your database schema with Typesaurus.
If you’re looking for more advanced schema designing tips, check out the Designing schema guide.
schema
You define database structure by importing schema
from typesaurus
and describing each collection using $
helper:
Inferring schema
You’ll find it handy to use Typesaurus.Schema
type to expose your defined schema types:
→ Read more about inferring schema
Subcollections
To define a subcollection, use sub
method on the helper $
:
→ Read more about defining subcollections
To access a subcollection:
→ Read more about accessing subcollections
Renaming collection
If you want to use a different path to access Firestore (e.g. to keep legacy naming), you can use name
method:
To Firestore it will be known as billing
, so documents will have paths like billing/4cQfqEdukBNhNJOaz5tzIFoxwCG2
.
To your app, you’ll use the alias subscriptions:
→ Read more about renaming collections