Check if a node is a primary key

Verified
Added by iNTERFACEWARE

Use node.isKey() to check if a node is the primary key for a database table, this method only for table node trees

Source Code
   -- create a tables node tree to use
   local Out = db.tables{vmd = 'example/demo.vmd', name = Name}      

   -- test if the "Id" field is the Primary Key for patient
   local iskey = Out.patient[1].Id:isKey()
   --> true
   
   -- test if the "PatientId" field is the Primary Key for kin
   local iskey = Out.kin[1].PatientId:isKey()
   --> false
Description
Use node.isKey() to check if a node is the primary key for a database table, this method only for table node trees
Usage Details

Use node.isKey() to check if a node is the primary key for a database table.

Note: The node.isKey() function only works with table node trees.

How to use the snippet:

  • Paste the code into your script