This is a utility class to simulate a database.
| oscar. | This 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. | |
| Functions | |
| addTable | Adds a new table to the database object |
| addRecord | Adds a record to a table |
| search | Searchs a table based on a user defined query. |
| Constants | |
| CLASS_NAME |
addRecord : function( tableName, data )
Adds a record to a table
| Parameters: | {String} tableName - {Array} records |
| Returns: | The number of records in the table. |
database.addRecord(‘developers’,[‘0,’developer1’, ‘developer1@caris.com’]); database.addRecord(‘developers’,[‘1,’developer2’, ‘developer2@caris.com’]);
search : function( tableName, query, execute )
Searchs a table based on a user defined query.
| Parameters: | {String} tableName - {String} query - {Function} execute |
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;
});
Adds a new table to the database object
addTable : function( tableName, columns )
Adds a record to a table
addRecord : function( tableName, data )
Searchs a table based on a user defined query.
search : function( tableName, query, execute )