DataMgr 2.2 Documentation: checkFields

checkFields

One option when loading seed data and using permanentRows="true" (to have DataMgr force the existence of the data even for already existing tables), is to only load the data based on certain fields.

<data table="genPrograms" permanentRows="true" checkFields="ProgramName,ZipFinal">
   <row
      ProgramName="Admins"
      Folder="admins"
      Description="I manage site administrators and administrative logins."
      isDefault="1"
      isStarter="1"
      ZipFinal="admins.zip"
   />
   <row
      ProgramName="Bug Tracker"
      Folder="bugs"
      Description="I track errors and bugs."
      isDefault="1"
      ZipFinal="bugs.zip"
   />
   <row
      ProgramName="Events Calendar"
      Folder="events"
      Description="I manage events and optionally display on calendar - includes repeating events."
      isDefault="1"
      ZipFinal="events.zip"
   />
</data>

This will have DataMgr create records only based on the ProgramName and ZipFinal fields while allowing you to specify the values of the other fields as well.

onexists

With the "checkFields" attribute, comes the "onexists" attribute. This indicates what DataMgr should do if a record exists for a data row (based on matching the fields in the "checkFields" attribute):

<data table="genPrograms" permanentRows="true" checkFields="ProgramName,ZipFinal" onexists="update">
   <row
      ProgramName="Admins"
      Folder="admins"
      Description="I manage site administrators and administrative logins."
      isDefault="1"
      isStarter="1"
      ZipFinal="admins.zip"
   />
   <row
      ProgramName="Bug Tracker"
      Folder="bugs"
      Description="I track errors and bugs."
      isDefault="1"
      ZipFinal="bugs.zip"
   />
   <row
      ProgramName="Events Calendar"
      Folder="events"
      Description="I manage events and optionally display on calendar - includes repeating events."
      isDefault="1"
      ZipFinal="events.zip"
   />
</data>