Fetch method tricks
'this' trick
When fetching a type which has as property another type, you can use the 'this' keyword in the 'include' field of the fetch spec to get the entire subordinate object. for example,
TypeA.c3typ:
entity type TypeA schema name "TypeA" { name: string child: TypeB }
Fetch command:
TypeA.fetch({'include': 'child.this'})
c3.TypeA.fetch({'include': 'child.this'})
Clearing Metadata Errors
Whenever you provision a C3 package to your tag, you will get a multitude of metadata warnings, and in some cases errors. This results in the following yellow or red banner at the top of your static console.
to clear these errors, simply issue
DbMetadataIssue.removeAll()
in the static console or
c3.DbMetadataIssue.removeAll()
through a connected python session.
Cleaning your Tag
When developing a C3 package, you frequently need to provision and re-provision progressively changing versions of a given package. This can result in older versions of your data lingering on your Tag even though you're no longer using it. Additionally, when you use your tag for a different package, you may leave behind old data which is not used.
There are two options for cleaning data.
Cleaning data from specific Types individually
Suppose you want to remove the data associated with the Type 'TypeName' All that's needed in this case is the 'removeAll' command. As follows:
TypeName.removeAll()
for JavaScript, and
c3.TypeName.removeAll()
for Python.
Cleaning all data from the Tag
You can remove all data from your tag with the `removeData` method. Please be aware, that not all users are authorized to do this.
Tag.removeData()
for JavaScript, and
c3.Tag.removeData()
for Python.
Warning: Please be aware that this command will remove all data from your tag. Please be sure you are really finished using that data, or back it up if necessary.
Checking Your Authorization
For some of the above commands, you may not be authorized to execute it. To check this, you can use the Authorizer Type. For example, to check whether Tag.removeData is allowed, execute the following in JavaScript:
Authorizer.isAuthorized("Tag", "removeData")
or
Authorizer.actionAuthzRoles({typeName: {typeName: 'Tag'}, action: 'removeData'})
and the same in Python would be:
c3.Authorizer.isAuthorized("Tag", "removeData")
or
c3.Authorizer.actionAuthzRoles(spec={'typeName': {'typeName': 'Tag'}, 'action': 'removeData'})
Checking your C3 Server version
Sometimes you may need to know the version of the C3 server you're using. You can do this from the static console with the following:
server_version = Cluster.hosts()[0].serverInfo.buildCITag
Checking the currently provisioned package
c3Grid(TagProvisionLog.fetch({ order: "descending(deployDate)", limit: 1 }))