05 / 26Part 1: Define your first entityBeginner
Create your first entity
Here you define a Book entity in Rell so your dapp can store book records and query them.
Define the Book entity
A Rell entity plays the same role as a table in a relational database. The Book entity holds the data for each book.
Add the entity definition
Add this code to src/main/entities.rell:
entity book { key isbn: text; title: text; author: text;}Code explanation
entitykeyword: Declares a new entity, much like creating a database table.- Attributes:
key isbn: text: Makesisbnthe unique identifier for every book. Marking it withkeyenforces uniqueness and adds an index on the field, so queries on it run faster. Thetexttype stores the value as a string.title: textandauthor: text: Hold the book's title and author, each as text.
The Book entity is now ready to use in your decentralized application.
Written for this site from Chromia’s public course. Code samples are the course’s own.