In the preceding sequence, seedText is the merge patch. Its temporary names #_ada, #_bob and #_cy create people; the link from Bob refers to Ada in the same patch.
The special temporary ID #_tx refers to the transaction that commits this patch. Its object adds metadata to that transaction: here, author smoke and reason seed. These fields describe the commit, rather than creating another person. A link to #_tx in the same patch resolves to the transaction's ID. Transaction metadata accompanies data changes; it cannot create a transaction on its own.
Parse that selected-format patch and pass its native document to the database merge-patch operation. The operation commits the facts and returns a commit record with the transaction and written entity IDs. Keep the IDs you need; temporary names are scoped to this patch, not durable application identifiers.
Store people and query their names
seedText holds this document:
#_ada {name Ada
role engineer
age 36}
#_bob {name Bob
role engineer
age 41
mentor {#link #_ada}}
#_cy {name Cy
role designer
age 29}
#_tx {author smoke
reason seed}
queryText holds this document:
find [?name]
where [[?e name ?name]]
orderBy [?name]
opened, err := stardust.Open(databasePath, stardust.Options{})
if err != nil {
return err
}
defer opened.Close()
seed, err := stardust.Parse(seedText, stardust.DUST)
if err != nil {
return err
}
defer seed.Close()
if _, err := opened.MergePatch(seed, nil); err != nil {
return err
}
definition, err := stardust.Parse(queryText, stardust.DUST)
if err != nil {
return err
}
defer definition.Close()
query, err := opened.Query(definition)
if err != nil {
return err
}
defer query.Close()
rows, err := query.Run(nil, stardust.RunOptions{}, nil)
if err != nil {
return err
}
defer rows.Close()
result, err := rows.Next()
if err != nil {
return err
}
defer result.Close()[{name Ada} {name Bob} {name Cy}]The captured result lists Ada, Bob and Cy. The create and query steps explain the same single commit; do not rerun the patch just to advance the tutorial. See Queries and mutations.