Add dateCreated and dateModified columns to itemNotes
Update itemNotes.dateModified on item update
This commit is contained in:
parent
3f27a12b0f
commit
4904c04e3e
3 changed files with 9 additions and 5 deletions
|
@ -710,7 +710,8 @@ Scholar.Item.prototype.addNote = function(text){
|
|||
**/
|
||||
Scholar.Item.prototype.updateNote = function(noteID, text){
|
||||
Scholar.DB.beginTransaction();
|
||||
var sql = "UPDATE itemNotes SET note=? WHERE itemID=? AND noteID=?";
|
||||
var sql = "UPDATE itemNotes SET note=?, dateModified=CURRENT_TIMESTAMP "
|
||||
+ "WHERE itemID=? AND noteID=?";
|
||||
Scholar.DB.query(sql,
|
||||
[{'string':text}, {'int':this.getID()}, {'int':noteID}]
|
||||
);
|
||||
|
@ -753,7 +754,8 @@ Scholar.Item.prototype.getNote = function(noteID){
|
|||
* Returns an array of noteIDs for this item
|
||||
**/
|
||||
Scholar.Item.prototype.getNotes = function(){
|
||||
var sql = "SELECT noteID FROM itemNotes WHERE itemID=" + this.getID();
|
||||
var sql = "SELECT noteID FROM itemNotes WHERE itemID=" + this.getID()
|
||||
+ " ORDER BY dateCreated";
|
||||
return Scholar.DB.columnQuery(sql);
|
||||
}
|
||||
|
||||
|
|
|
@ -370,7 +370,7 @@ Scholar.Schema = new function(){
|
|||
//
|
||||
// Change this value to match the schema version
|
||||
//
|
||||
var toVersion = 20;
|
||||
var toVersion = 21;
|
||||
|
||||
if (toVersion != _getSchemaSQLVersion()){
|
||||
throw('Schema version does not match version in _migrateSchema()');
|
||||
|
@ -385,7 +385,7 @@ Scholar.Schema = new function(){
|
|||
// Each block performs the changes necessary to move from the
|
||||
// previous revision to that one.
|
||||
for (var i=parseInt(fromVersion) + 1; i<=toVersion; i++){
|
||||
if (i==20){
|
||||
if (i==21){
|
||||
_initializeSchema();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
-- 20
|
||||
-- 21
|
||||
|
||||
DROP TABLE IF EXISTS version;
|
||||
CREATE TABLE version (
|
||||
|
@ -65,6 +65,8 @@
|
|||
noteID INT,
|
||||
itemID INT,
|
||||
note TEXT,
|
||||
dateCreated DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
dateModified DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (noteID),
|
||||
FOREIGN KEY (itemID) REFERENCES items(itemID)
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue