Getting started Recipes in two minutes
Recipes in two minutes
What a recipe is, what it consists of, and why there are no paths or strings around it.
A recipe is a named block of actions. It can depend on other recipes and use their results. Users write their own recipes; there are no built-in “system recipes”. What is built in is a set of commands and tool adapters (build, git, files, dat), but a command is not a recipe by itself.
What a recipe consists of
- A name. Free-form. Other recipes refer to it.
- Dependencies. Which recipes must run first.
- A body. What the recipe does: takes data, transforms it, puts the result somewhere.
A recipe works with objects, not strings
In Anchor Code, server and client are typed objects. They are not file paths and not a blob of JSON settings. The selected project is supplied automatically, which is why a recipe never says project..
// DRAFT. Shows the idea, does not run.
recipe BuildLcoin {
dependsOn(GenerateShops);
GenerateShops.output
.select(server.shops.lcoin.id)
.replaceIn(client.dat.shopProducts);
}
How to read it: GenerateShops has to finish first. Then, from its result, the shop that is bound as L-Coin in the selected project is taken and written into the matching client table.
Draft. The unquoted
recipekeyword, thedependsOn(...)form, theoutputproperty, theselectandreplaceInmethods and theshopProductsname are not approved. This is a sketch of the meaning, not a contract and not executable code.
What is guaranteed already
- Visibility is not authorization. A recipe that can read data does not thereby get the right to change it.
- Preview comes first, action second. Nothing on the server, in the client, in Git or in production is changed silently.
- If the target is ambiguous, that is an error with an explanation, not a guess.
Next: Your first recipe.