Module activerecord
Tables
MESSAGE | Network message enumeration |
Helpers
library:BuildObjectsFromSQL(model, result[, bSingleResult]) | Creates objects from the given SQL result. |
library:BuildQuery(type, data) | Builds an SQL query given the type. |
library:CheckObjectRequestCondition(modelName, player) | Returns true if the player is able to request object data from the given model. |
library:FilterPlayers(func) | Returns a table of players that passed the given filter function. |
library:GetCallbackArgument(...) | Returns the first function argument from the given varargs. |
library:GetName() | Returns the unique full name of the project. |
library:GetObjectTable(object) | Returns a table of an object's properties. |
library:IsObject(var) | Returns true if the given object is an activerecord object. |
library:NetworkModel(model) | Networks a model to clients. |
library:NetworkObject(object) | Networks an object to clients. |
library:OnPrefixSet() | Called when the prefix for the project has been set. |
library:PackTable(table) | Serializes and compresses a table for networking. |
library:PerformModelSync(model) | Pulls all of a model's objects from the database and stores it in memory. |
library:Pluralize(string) | Pluralize a string. |
library:QueuePush(type, data) | Queues a database push with the given type. |
library:ReadNetTable() | Reads a table from the currently active net message. |
library:SetPrefix(prefix) | Sets the prefix used when creating tables. |
library:SetupModel(name, setup) | Creates a model and does the appropriate database/networking setup for it. |
library:StartNetMessage(type) | Begins an activerecord net message. |
library:Think() | Handles some database stuff. |
library:UnpackTable(string) | Decompresses and deserializes a string into a table. |
library:WriteNetTable(data) | Writes a table to the currently active net message. |
Class: Schema
library.meta.schema:Boolean(name) | Adds a boolean to the model schema. |
library.meta.schema:Integer(name) | Adds an integer to the model schema. |
library.meta.schema:OnSync(callback) | Sets callback executed when syncing is completed. |
library.meta.schema:String(name) | Adds a string to the model schema. |
library.meta.schema:Sync(bValue) | Sets whether or not the model will sync all in-memory objects with the database. |
library.meta.schema:Text(name) | Adds a text field to the model schema. |
Class: Replication
library.meta.replication:Condition(callback) | Sets the replication condition function. |
library.meta.replication:Enable(bValue) | Enables replication for the model. |
Class: Object
library.meta.object:Save() | Commits the object to the database and networks it to clients if applicable. |
library.meta.object:__tostring() | Returns a string representation of the object. |
Class: Model
library.meta.model:All(...) | Returns all objects with this model. |
library.meta.model:FindBy(key, value, ...) | Returns an object with a matching key/value pair. |
library.meta.model:First(...) | Returns the first object with this model |
library.meta.model:New() | Creates a new object. |
Tables
- MESSAGE
-
Network message enumeration
Fields:
- COMMIT Client-to-server object commit
- SCHEMA Model schema update
- REQUEST Object fetch request
- UPDATE Object replication update
- SYNC Full sync of objects
Helpers
- library:BuildObjectsFromSQL(model, result[, bSingleResult])
-
Creates objects from the given SQL result.
Parameters:
- model Model to build object from
- result SQL result set
- bSingleResult Whether or not this should return a single object (optional)
Returns:
-
Table of objects, or a single object as specified by bSingleResult
- library:BuildQuery(type, data)
-
Builds an SQL query given the type.
Parameters:
- type The type of query
- data Any extra data
Returns:
-
An SQL query object
- library:CheckObjectRequestCondition(modelName, player)
-
Returns true if the player is able to request object data from the given model.
Parameters:
- modelName Name of the model
- player Player to check with
Returns:
-
Whether or not the player is allowed to request object data
- library:FilterPlayers(func)
-
Returns a table of players that passed the given filter function.
Parameters:
- func The filter function to run players through
Returns:
-
A table of players
- library:GetCallbackArgument(...)
-
Returns the first function argument from the given varargs. Currently kind of useless.
Parameters:
- ...
Returns:
-
Callback function
- library:GetName()
-
Returns the unique full name of the project. Mainly used for networking.
Returns:
-
Name of project
- library:GetObjectTable(object)
-
Returns a table of an object's properties. Useful for iterating over properties.
Parameters:
- object Object to get properties from
Returns:
-
Table of key/values for the given object
- library:IsObject(var)
-
Returns true if the given object is an activerecord object.
Parameters:
- var Any object
Returns:
-
Whether or not var is an activerecord object
- library:NetworkModel(model)
-
Networks a model to clients. This does not check if replication is applicable for the object's model, so you'll have to do it yourself!
Parameters:
- model Model to network
- library:NetworkObject(object)
-
Networks an object to clients. This does not check if replication is applicable for the object's model, so you'll have to do it yourself!
Parameters:
- object Object to network
- library:OnPrefixSet()
- Called when the prefix for the project has been set. Currently used for setting up networking events. This should NOT be overridden, otherwise things will break BADLY!
- library:PackTable(table)
-
Serializes and compresses a table for networking.
Parameters:
- table Table of data
Returns:
- Packed data string
- Length of data
- library:PerformModelSync(model)
-
Pulls all of a model's objects from the database and stores it in memory.
Parameters:
- model The model to sync
- library:Pluralize(string)
-
Pluralize a string.
Parameters:
- string String to pluralize
Returns:
-
Pluralized string
- library:QueuePush(type, data)
-
Queues a database push with the given type.
Parameters:
- type The type of data push
- data The data to push
- library:ReadNetTable()
-
Reads a table from the currently active net message.
Returns:
-
Table of data
See also:
- library:SetPrefix(prefix)
-
Sets the prefix used when creating tables. An underscore is appended to the end of the given prefix. Default is "ar".
Parameters:
- prefix String to use as prefix
- library:SetupModel(name, setup)
-
Creates a model and does the appropriate database/networking setup for it.
Parameters:
- name Name of the model.
- setup Function to execute when setting up the model.
- library:StartNetMessage(type)
-
Begins an activerecord net message.
Parameters:
- type Message type
See also:
- library:Think()
- Handles some database stuff. Should be called constantly - about every second is enough. This is already done automatically.
- library:UnpackTable(string)
-
Decompresses and deserializes a string into a table.
Parameters:
- string Packed data string
Returns:
-
Table of data
See also:
- library:WriteNetTable(data)
-
Writes a table to the currently active net message.
Parameters:
- data Table of data
See also:
Class: Schema
- library.meta.schema:Boolean(name)
-
Adds a boolean to the model schema.
Parameters:
- name Name of field
- library.meta.schema:Integer(name)
-
Adds an integer to the model schema.
Parameters:
- name Name of field
- library.meta.schema:OnSync(callback)
-
Sets callback executed when syncing is completed. Only called if
schema:Sync(true)
has been set.Parameters:
- callback Function to execute
- library.meta.schema:String(name)
-
Adds a string to the model schema.
Parameters:
- name Name of field
- library.meta.schema:Sync(bValue)
-
Sets whether or not the model will sync all in-memory objects with the database.
Parameters:
- bValue true/false
- library.meta.schema:Text(name)
-
Adds a text field to the model schema.
Parameters:
- name Name of field
Class: Replication
- library.meta.replication:Condition(callback)
-
Sets the replication condition function. Note that this is REQUIRED when you're using replication.
A boolean return type is expected from the filter function.
Parameters:
- callback Function to use as the filter
- library.meta.replication:Enable(bValue)
-
Enables replication for the model.
Parameters:
- bValue Whether or not to enable/disable
Class: Object
- library.meta.object:Save()
- Commits the object to the database and networks it to clients if applicable.
- library.meta.object:__tostring()
-
Returns a string representation of the object. This will include its model and properties.
Returns:
-
String representation of object
Class: Model
- library.meta.model:All(...)
-
Returns all objects with this model.
Parameters:
- ...
Returns:
-
Table of objects
- library.meta.model:FindBy(key, value, ...)
-
Returns an object with a matching key/value pair.
Parameters:
- key Name of the property to match
- value Value of the property to match
- ...
Returns:
-
An object
- library.meta.model:First(...)
-
Returns the first object with this model
Parameters:
- ...
Returns:
-
An object
- library.meta.model:New()
-
Creates a new object.
Returns:
-
An object defined by the given model class.