Dongle/Database system

The database system is very simple, but provides a lot of functionality. This system allows the developer the system necessary to support multiple profiles within their addon, allowing the user to change and control their profile.
==Database Sections==
A database is registered using the InitializeDB() method call, this returns a dongle database object. This object has a number of subtables:
* db.profile - This should be the default manner of storage for 90% of all addons. This section simply points to the users current profile, which should contain all their options and data.
* db.char - This section is character specific, and should only be used if you absolutely must ensure separate sections of the database for each character.
* db.realm - This section is realm specific, and should only be used if you absolutely must ensure separate sections of the database for each character.
* db.class - This section is class specific, and should only be used if you absolutely must ensure separate sections of the database for each class.
* db.faction - This section is faction specific, and should only be used if you absolutely must ensure separate sections of the database for each class.
* db.factionrealm - This section is faction and realm specific, and should only be used if you absolutely must ensure separate sections of the database for each faction and realm.
* db.global - This section is global to all users, and should only be used if you absolutely must use a global section of the database.
There are very few reasons you should need to use any section other than db.profile, but they have been provided for convenience. If you do not use a section, no tables will be created, and no data will be saved, automatically.
==Profiles==
When designing your addon, ask yourself if the user would ever want to share the same options between two characters, or copy data from one profile to another. Typically the answer to this question is "Yes", and this is the purpose for profiles.
When you initialize a database, you are able to supply a defaultProfile, which specifies the profile that will be used if the user hasn't already selected one. By default this is "Charname of Realmname", so each user will start off with character specific profiles by default.
The power of profiles is that another user can "Select" any profile in the system, and the options and data will be shared between those two users. This means you can configure Clique for one of your characters, log onto a second character, and select the exact same configuration on another character, without needing to set it up again. Any changes to one profile are made for all users of that profile-- but this is for the user to manage.
Profiles can have any name, "Cladhaire of Stormrage", "MonkeyButt", "Healers123", and there are no restrictions.
Dongle provides a number of API functions which make implementing a front-end to profiles relatively easy. At some point, common slash commands may be provided to serve this purpose.
Category:Dongle