The API

The API of SQLite Persist is extremely simple, as it was intended to be.  That means there are only two public methods to access: Save and Load (+1 overload).

Load(of t)(id as Long)

This returns an object of the type specified for the provided ID value.  How does it know what the ID field is?  You flag it with the PKAttribute.

If the database does not exist, as in nothing has ever been saved, the return will be Nothing/NULL.  If the database exists but the table does not, the return will be Nothing/NULL.

Load(of t)(ParamArray criteria as Criteria()())

This returns an array of objects of the type specified for the given criteria.  If no criteria is given, all the objects are returned.  How do you specify criteria?  You use the Criteria class.  How do you specify multiple criteria?  You use an array of Criteria for your criteria and they will be evaluated using AND.  How do you specify criteria using OR?  You use another array of Criteria and the two arrays will be evaluated using OR.  How do you use more criteria?  You can have as many arrays of Criteria to create as many AND/OR conditions as you want.  Simply put, all criteria in an array is an AND block, all arrays are OR blocks.

If the database does not exist, as in nothing has ever been saved, the return will be Nothing/NULL.  If the database exists but the table does not, the return will be an empty array.

Save(obj as object)

This saves an object to the database.  If the database does not exist, it will be created.  If the table does not exist, it will be created.

There are two attributes you can decorate your class with to utilize special features in the Save method.  These are the PKAttribute and the SingletonAttribute.

PKAttribute

This attribute must be applied to a private/protected field in your class and must be an Integer or Long.  The SQLite Persist class will use this as an auto-incrementing identity field.  The field does not need to be exposed outside the class.  You will need this in order to Load or Save a specific record.  The few cases you would not need it would be for a read-only log where an individual record would never get read or updated, or when using a SingletonAttribute.

SingletonAttribute

This attribute must be applied to a class.  The attribute ensures that there is only ever one row in the table.  This is primarily useful for storing application settings or other single-use objects.