Plugin:MirLua/Module/m database
Jump to navigation
Jump to search
Allows you to access data and contacts in user profile database.
Include module: local db = require('m_database')
<translate> Note</translate>
Parameters written in bold italics are obligatory.
Parameters written in bold italics are obligatory.
Contacts
Contacts
Iterator for list of contacts.
- Parameters
- name
- Type: string
- Protocol name.
- Result
- Type: number
- Returns contact number. The list ends in element with nil value.
- Example
for hContact in db.Contacts('JABBER_1') do
print(db.GetSetting(hContact, 'JABBER_1', 'Nick'))
end
Events
GetEventCount
Number of events for a contact.
- Parameters
- hContact
- Type: number
- Contact number.
- Result
- Type: number
- Returns number of events.
- Example
db.GetEventCount(hContact)
Events
Iterator for contact's event list from the first to the last.
- Parameters
- hContact
- Type: number
- Contact number.
- Result
- Type: number
- Returns event number. The list ends in element with nil value.
- Example
for hEvent in db.Events(hContact) do
local event = totable(hEvent, "DBEVENTINFO")
print(event.Timestamp, event.Blob)
end
EventsFromEnd
Iterator for contact's event list from the last to the first.
- Parameters
- hContact
- Type: number
- Contact number.
- Result
- Type: number
- Returns event number. The list ends in element with nil value.
- Example
for hEvent in db.EventsFromEnd(hContact) do
local event = totable(hEvent, "DBEVENTINFO")
print(event.Timestamp, event.Blob)
end
Settings
GetSetting
Returns value of a setting.
- Parameters
- hContact
- Type: number
- Contact number or nil.
- module
- Type: string
- Module name.
- setting
- Type: string
- Setting name.
- value
- Type: number, string
- Default value.
- Result
- Type: number
- Returns value of a setting or default value or nil.
- Example
db.GetSetting(nil, 'test', 'some')
Settings
Iterator for module (group of settings).
- Parameters
- hContact
- Type: number
- Contact number or nil.
- module
- Type: string
- Module name.
- Result
- Type: number
- Returns module name. The list ends in element with nil value.
- Example
for setting in db.Settings(nil, 'CList') do
local message = string.format("%s/%s = ", 'CList', setting, ...)
.. db.GetSetting(nil, 'CList', setting)
print(message)
end
WriteSetting
Saves a value to database.
- Parameters
- hContact
- Type: number
- Contact number or nil.
- module
- Type: string
- Module name.
- setting
- Type: string
- Setting name.
- Result
- Type: boolean
- Returns true in case of success, else false.
- Example
db.WriteSetting(nil, 'test', 'some', true)
DeleteSetting
Deletes a setting.
- Parameters
- hContact
- Type: number
- Contact number or nil.
- module
- Type: string
- Module name.
- setting
- Type: string
- Setting name.
- Result
- Type: boolean
- Returns true in case of success, else false.
- Example
db.DeleteSetting(nil, 'test', 'some')
DeleteModule
Deletes a module (group of settings).
- Parameters
- hContact
- Type: number
- Contact number or nil.
- module
- Type: string
- Module name.
- Result
- Type: boolean
- Returns true in case of success, else false.
- Example
db.DeleteModule(nil, 'test')