- Index
- »
- hx
- »
- HxCoreFuncs
type
methods
about |
Return |
---|---|
commit |
Commit one or more diffs to the folio database. |
context |
Get the current context as a Dict with the following tags |
diff |
Construct a modification "diff" used by |
isSteadyState |
Return |
isWatched |
Return if given record is under at least one watch. |
libAdd |
Enable a library by name in the runtime |
libRemove |
Disable a library by name in the runtime |
libStatus |
Return grid of enabled libs and their current status. |
passwordSet |
Store a password key/val pair into current project's password store. |
pods |
Return list of installed Fantom pods |
read |
Read from database the first record which matches filter. |
readAll |
Reall all records from the database which match the filter. |
readAllStream |
Reall all records which match filter as stream of Dict records. |
readAllTagNames |
Return the intersection of all tag names used by all the records matching the given filter. |
readAllTagVals |
Return the range of all the values mapped to a given tag name used by all the records matching the given filter. |
readById |
Read a record from database by |
readByIdPersistentTags |
Given record id, read only the persistent tags from Folio. |
readByIdTransientTags |
Given record id, read only the transient tags from Folio. |
readByIds |
Read a list of record ids into a grid. |
readByIdsStream |
Read a list of ids as a stream of Dict records. |
readCount |
Return the number of records which match the given filter expression. |
readLink |
Read a record Dict by its id for hyperlinking in a UI. |
services |
Grid of installed services. |
stripUncommittable |
Strip any tags which cannot be persistently committed to Folio. |
toRec |
Coerce a value to a record Dict |
toRecId |
Coerce a value to a Ref identifier |
toRecIdList |
Coerce a value to a list of Ref identifiers |
toRecList |
Coerce a value to a list of record Dicts |
tzdb |
Return the installed timezone database as Grid with following columns |
unitdb |
Return the installed unit database as Grid with following columns |
watchAdd |
Add a grid of recs to an existing watch and return the grid passed in. |
watchClose |
Close an open watch by id. |
watchOpen |
Open a new watch on a grid of records. |
watchPoll |
Poll an open watch and return all the records which have changed since the last poll. |
watchRemove |
Remove a grid of recs from an existing watch and return grid passed in. |
xetoReload |
Reload all the Xeto libraries |
Slot Details
about
commit
@Axon { admin=true }
static Obj? commit(Obj diffs)
Commit one or more diffs to the folio database. The argument may be one of the following:
If one diff is passed, return the new record. If a list of diffs is passed return a list of new records.
This is a synchronous blocking call which will return the new record or records as the result.
Examples:
// add new record newRec: commit(diff(null, {dis:"New Rec!"}, {add})) // add someTag to some group of records readAll(filter).toRecList.map(r => diff(r, {someTag})).commit
context
Get the current context as a Dict with the following tags:
username
for current useruserRef
id for current userlocale
current locale
SkySpark tags:
projName
if evaluating in context of a projectnodeId
local cluster node idruleRef
if evaluating in context of a rule engineruleTuning
if evaluating in context of rule engine
diff
@Axon
static Diff diff(Dict? orig, Dict? changes, Dict? flags := null)
Construct a modification "diff" used by commit
. The orig should be the instance which was read from the database, or it may be null only if the add flag is passed. Any tags to add/set/remove should be included in the changes dict.
The following flags are supported:
add
: indicates diff is adding new recordremove
: indicates diff is removing record (in general you should addtrash
tag instead of removing)transient
: indicate that this diff should not be flushed to persistent storage (it may or may not be persisted).force
: indicating that changes should be applied regardless of other concurrent changes which may be been applied after the orig version was read (use with caution!)
Examples:
// create new record diff(null, {dis:"New Rec", someMarker}, {add}) // create new record with explicit id like Diff.makeAdd diff(null, {id:151bd3c5-6ce3cb21, dis:"New Rec"}, {add}) // set/add dis tag and remove oldTag diff(orig, {dis:"New Dis", -oldTag}) // set/add val tag transiently diff(orig, {val:123}, {transient})
isSteadyState
@Axon
static Bool isSteadyState()
Return HxRuntime.isSteadyState
isWatched
libAdd
libRemove
libStatus
passwordSet
@Axon { admin=true }
static Void passwordSet(Obj key, Str? val)
Store a password key/val pair into current project's password store. The key is typically a Ref of the associated record. If the val
is null, then the password will be removed. See Folio.
passwordSet(@abc-123, "password") passwordSet(@abc-123, null)
pods
read
@Axon
static Dict? read(Expr filterExpr, Expr checked := Literal.trueVal)
Read from database the first record which matches filter. If no matches found throw UnknownRecErr or null based on checked flag. If there are multiple matches it is indeterminate which one is returned. See readAll
for how filter works.
Examples:
read(site) // read any site rec read(site and dis=="HQ") // read site rec with specific dis tag read(chiller) // raise exception if no recs with chiller tag read(chiller, false) // return null if no recs with chiller tag
readAll
@Axon
static Grid readAll(Expr filterExpr, Expr? optsExpr := null)
Reall all records from the database which match the filter. The filter must an expression which matches the filter structure. String values may parsed into a filter using parseFilter()
function.
Options:
limit
: max number of recs to returnsort
: sort by display name
Examples:
readAll(site) // read all site recs readAll(equip and siteRef==@xyz) // read all equip in a given site readAll(equip, {limit:10}) // read up to ten equips readAll(equip, {sort}) // read all equip sorted by dis
readAllStream
readAllTagNames
@Axon
static Grid readAllTagNames(Expr filterExpr)
Return the intersection of all tag names used by all the records matching the given filter. The results are returned as a grid with following columns:
name
: string name of the tagkind
: all the different value kinds separated by "|"count
: total number of recs with the tag Also seereadAllTagVals
andgridColKinds()
.
Examples:
// read statistics on all tags used by equip recs readAllTagNames(equip)
readAllTagVals
@Axon
static Grid readAllTagVals(Expr filterExpr, Expr tagName)
Return the range of all the values mapped to a given tag name used by all the records matching the given filter. This method is capped to 200 results. The results are returned as a grid with a single val
column. Also see readAllTagNames
.
Examples:
// read grid of all unique point unit tags readAllTagVals(point, "unit")
readById
@Axon
static Dict? readById(Ref? id, Bool checked := true)
Read a record from database by id
. If not found throw UnknownRecErr or return null based on checked flag. In Haxall all refs are relative, but in SkySpark refs may be prefixed with something like "p:projName:r:". This function will accept both relative and absolute refs.
Examples:
readById(@2b00f9dc-82690ed6) // relative ref literal readById(@:demo:r:2b00f9dc-82690ed6) // project absolute literal readById(id) // read using variable readById(equip->siteRef) // read from ref tag
readByIdPersistentTags
readByIdTransientTags
readByIds
@Axon
static Grid readByIds(Ref[] ids, Bool checked := true)
Read a list of record ids into a grid. The rows in the result correspond by index to the ids list. If checked is true, then every id must be found in the database or UnknownRecErr is thrown. If checked is false, then an unknown record is returned as a row with every column set to null (including the id
tag). Either relative or project absolute refs may be used.
Examples:
// read two relative refs readByIds([@2af6f9ce-6ddc5075, @2af6f9ce-2d56b43a]) // read two project absolute refs readByIds([@p:demo:r:2af6f9ce-6ddc5075, @p:demo:r:2af6f9ce-2d56b43a]) // return null for a given id if it does not exist readByIds([@2af6f9ce-6ddc5075, @2af6f9ce-2d56b43a], false)
readByIdsStream
readCount
readLink
services
stripUncommittable
@Axon
static Obj stripUncommittable(Obj val, Obj? opts := null)
Strip any tags which cannot be persistently committed to Folio. This includes special tags such as hisSize
and any transient tags the record has defined. If val
is Dict, then a single Dict is returned. Otherwise val
must be Dict[] or Grid and Dict[] is returned. The mod
tag is stripped unless the {mod}
option is specified. The id
tag is not stripped for cases when adding records with swizzled ids; pass {-id}
in options to strip the id
tag also.
Examples:
// strip uncommittable tags and keep id toCommit: rec.stripUncommittable // strip uncommittable tags and the id tag toCommit: rec.stripUncommittable({-id}) // strip uncommittable tags, but keep id and mod toCommit: rec.stripUncommittable({mod})
toRec
toRecId
toRecIdList
toRecList
tzdb
unitdb
watchAdd
watchClose
@Axon
static Obj? watchClose(Str watchId)
Close an open watch by id. If the watch does not exist or has expired then this is a no op. Also see HxWatch.close
and Watches.
watchOpen
watchPoll
@Axon
static Grid watchPoll(Obj watchId)
Poll an open watch and return all the records which have changed since the last poll. Raise exception if watchId doesn't exist or has expired. Also see HxWatch.poll
and Watches.