Hello,
Can I reference and pass an Ontology object into a code repository? If not, what is the best approach? Should I create a new view/data set based on the object, and then reference that?
Thx!!
Hello,
Can I reference and pass an Ontology object into a code repository? If not, what is the best approach? Should I create a new view/data set based on the object, and then reference that?
Thx!!
Hey,
Yes you can. When you create a new Code Repository you’ll see the splash page which will prompt you to select what type of work you’ll be doing in the repo. For the first selection, choose Functions.
For the second selection, choose your preferred language/version (i.e., TypeScript v1, Python, TypeScript v2).
If you’re using TypeScript v1 (stable), you’ll see on the left a multipurpose side-panel with 4-6 icons. If you click on the one with a downward-facing arrow (Resource imports), you’ll see an Add button/dropdown, from which you can select Ontology.
You may be prompted to select which Ontology the assets you want to reference come from (most Foundry instances will have just one). Then you can browse through the list of all Object Types and Link Types in that Ontology, and click the + sign on each asset you want to use. Note that this will only install these assets in your repository, making them available for local import to any of the files.
To actually reference and pass individual Ontology objects, you will need to add an import statement (usually at the top of the src/index.ts file) where you use the API names of the Object Types you want to use. See below for an example import statement assuming the existence of two Object Types called Project Progress and Example Object Type:
// ... other imports
import {
Objects,
ObjectSet,
ProjectProgress,
ExampleObjectType
} from "@foundry/ontology-api";
// ... class definition with actual functions
Hope this helps!
yes, this helps, thx!!!