oscar.Util.Database

This is a utility class to simulate a database.

Summary
oscar.Util.DatabaseThis is a utility class to simulate a database.
Properties
events{OpenLayers.Events)
EVENT_TYPES {Array} - List of events this object will fire.
Constructor
new oscar.Util.Database
Functions
addTableAdds a new table to the database object
addRecordAdds a record to a table
searchSearchs a table based on a user defined query.
Constants
CLASS_NAME

Properties

events

{OpenLayers.Events)

EVENT_TYPES {Array} - List of events this object will fire.

Constructor

new oscar.Util.Database

Functions

addTable

addTable : function(tableName,
columns)

Adds a new table to the database object

Usage

database.addTable(‘developers’, [‘index’,’name’,’email’]);

addRecord

addRecord : function(tableName,
data)

Adds a record to a table

Parameters:{String} tableName - {Array} records
Returns:The number of records in the table.

Usage

database.addRecord(‘developers’,[‘0,’developer1’, ‘devel.nosp@m.oper1@cari.nosp@m.s.com’]); database.addRecord(‘developers’,[‘1,’developer2’, ‘devel.nosp@m.oper2@cari.nosp@m.s.com’]);

search

search : function(tableName,
query,
execute)

Searchs a table based on a user defined query.

Parameters:{String} tableName - {String} query - {Function} execute

Usage

database.search(‘developers’,’developer1’, function(table,query) { var results = []; for(var r in table.records) { var record = table.records[r]; if(record.name == query) { results.push(record); } } return results;

});

Constants

CLASS_NAME

addTable : function(tableName,
columns)
Adds a new table to the database object
addRecord : function(tableName,
data)
Adds a record to a table
search : function(tableName,
query,
execute)
Searchs a table based on a user defined query.