-
Notifications
You must be signed in to change notification settings - Fork 3
Library Reference
Gabriel Francisco edited this page Jul 17, 2022
·
7 revisions
-
string
name
: Identifier for the database -
string
driver
: Driver to be used, see drivers section -
optional
table
conninfo
: Connection information, accepts the following:-
string
address
: Host Address -
string
port
: Port to connect with -
string
database
: Database name -
string
user
: User Name -
string
password
: User Password
-
For Builtin SQLite
sqlier.Initialize("db_example", "sqlite")
For External MySQLoo
sqlier.Initialize("db_example", "mysqloo", {
address = "127.0.0.1",
port = "3306",
database = "db_example_database",
user = "username",
pass = "pass"
})
returns: Model
-
table
modelstruct
: Table that contains all the model information-
string
Table
: Table to store the Model information in -
string
optional
Database
: Database identifier for the model to be created in -
string
Identity
: Keyname of the Primary key for the model -
table
Columns
: Contains the columns of the Model, each column entry contains these methods:-
type
Type
: Type of the column -
any
Default
: Default value -
any
OptionalArgs
: These are optional, type specific arguments
-
-
Example Model
local User = sqlier.Model({
Table = "user",
Columns = {
Id = {
Type = sqlier.Type.Integer,
AutoIncrement = true
},
Name = {
Type = sqlier.Type.String
},
Rank = {
Type = sqlier.Type.String,
MaxLength = 15
},
SteamId64 = {
Type = sqlier.Type.SteamId64
},
CreateTimestamp = {
Type = sqlier.Type.Timestamp
}
},
Identity = "Id"
})
Usage of the previous model
local new_user = User({
Name = ply:Nick(),
SteamId = ply:SteamId64(),
Rank = "user"
})
new_user:save()
new_user.Rank = "donator"
new_user:save()
List of all databases, created with sqlier.Initialize
Contains one method, log(string prefix, string log, number severity)
, which prints out the information passed to it.
Is the metatable of all Models
Is the metatable of all ModelInstances
All the following are stored in the table sqlier.Type
Special Parameters:
-
MaxLength
: Defines the max length of the string (VARCHAR(MaxLength)
)
Special Parameters:
-
AutoIncrement
: Tells SQL to automatically increment this based on the current amount (AUTOINCREMENT
orAUTO_INCREMENT
)
No Special Parameters
(Identical to String
except a max of 17 chars)
No Special Parameters
No Special Parameters
No Special Parameters
No Special Parameters
No Special Parameters