-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This will allow us to define a sqllite module later, which we'll want to transition to in order to do away with document data storage as well as using a full blown mysql database for a simple scanner frontend.
- Loading branch information
1 parent
a9581aa
commit bc597b2
Showing
8 changed files
with
165 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
var baseproto = { | ||
_protoName: 'baseproto', | ||
|
||
isPrototypeOf: function(obj) { | ||
return obj._protoName && this._protoName === obj._protoName; | ||
}, | ||
|
||
getPrototypeOf: function() { | ||
return this._protoName; | ||
} | ||
} | ||
|
||
|
||
module.exports = baseproto; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
/** | ||
* define sqldatabase prototype | ||
**/ | ||
|
||
var baseproto = require('./baseproto.js'); | ||
|
||
var sqldatabase = { | ||
_protoName : 'sqldatabase', | ||
|
||
// define sqldatabase object properties | ||
connection : null, // holds the connection object to the SQL server or null if not connected | ||
eventEntryCreated : false, // flag indicating whether a SQL entry has been added (`events`) for current event | ||
hasData : false, // flag indicating whether SQL database table contains any data | ||
isBusy : false, // flag indicating whether a SQL query is currently ongoing | ||
isConnected : false, // flag indicating whether a connection to SQL server has been established | ||
|
||
/** | ||
* performs a query using the underlying database connection | ||
* | ||
* @param sqlQuery = {String} specifying SQL query to execute | ||
* @param callback = {Function} to call after operation has completed successfully | ||
**/ | ||
query : function(sqlQuery, callback) { | ||
throw "unimplemented query method"; | ||
}, | ||
|
||
/** | ||
* deletes entries from table where whereLogic applies | ||
* | ||
* @param sqlTableName = {Object} entry object from local 'database' object | ||
* @param whereLogic = {String} containing equality to use to target the selection of a specific row | ||
* @param callback = {Function} to call after operation has completed successfully | ||
* | ||
* for data protection, if @param whereLogic is 'null', nothing should be deleted / returned | ||
**/ | ||
deleteFrom : function(sqlTableName, whereLogic, callback) { | ||
throw "unimplemented deleteFrom method"; | ||
}, | ||
|
||
/** | ||
* safely closes the SQL server connection | ||
**/ | ||
end : function() { | ||
throw "unimplemented end method"; | ||
}, | ||
|
||
/** | ||
* inserts new entry to SQL database | ||
* | ||
* @param sqlTableName = {Object} entry object from local 'database' object | ||
* @param databaseColumns = {Array} containing names of SQL table columns to insert values into | ||
* @param valuesToAdd = {Array} containing entry values to add | ||
* @param callback = {Function} to call after operation has completed successfully | ||
**/ | ||
insertInto : function(sqlTableName, databaseColumns, valuesToAdd, callback) { | ||
throw "unimplemented insertInto method"; | ||
}, | ||
|
||
/** | ||
* selects entries from table, using passed logic | ||
* | ||
* @param sqlTableName = {Object} entry object from local 'database' object | ||
* @param databaseColumns = {Array} containing names of SQL table columns to select | ||
* @param whereLogic = {String} containing equality to use to target the selection of a specific row | ||
* @param callback = {Function} to call after operation has completed successfully | ||
* | ||
* if @param whereLogic is 'null', all rows are selected and returned | ||
**/ | ||
selectFrom : function(sqlTableName, databaseColumns, whereLogic, callback) { | ||
throw "unimplemented selectFrom method"; | ||
}, | ||
|
||
/** | ||
* updates entry in database table, using passed logic | ||
* | ||
* @param sqlTableName = {Object} entry object from local 'database' object | ||
* @param databaseColumns = {Array} containing names of SQL table columns to update values | ||
* @param updatedValues = {Array} containing updated entry values | ||
* @param whereLogic = {String} containing equality to use to target the update of a specific row | ||
* @param callback = {Function} to call after operation has completed successfully | ||
**/ | ||
update : function(sqlTableName, databaseColumns, updatedValues, whereLogic, callback) { | ||
throw "unimplemented update method"; | ||
} | ||
|
||
}; | ||
|
||
sqldatabase.__proto__ = baseproto; | ||
module.exports = sqldatabase; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters