Skip to content

Commit

Permalink
Added expense types
Browse files Browse the repository at this point in the history
  • Loading branch information
hemanth-s-a committed Mar 6, 2016
1 parent 76f23cb commit 182b2a1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ node_modules/
bower_components/

sql.json
*.txt
4 changes: 3 additions & 1 deletion Schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ CREATE TABLE User (
CREATE TABLE ExpenseType (
id int PRIMARY KEY AUTO_INCREMENT,
name varchar(50) NOT NULL,
description varchar(200)
description varchar(200),
parentId int DEFAULT NULL,
FOREIGN KEY(parentId) REFERENCES ExpenseType(id) ON UPDATE cascade ON DELETE cascade
);

CREATE TABLE Expenses (
Expand Down
4 changes: 4 additions & 0 deletions server/expenses.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ exports.getExpenseTypes = function(connection) {
};
};

function prepareGetExpenseTypes() {
return 'SELECT * FROM ExpenseType WHERE parentId IS NULL';
};

function prepareSaveExpense() {
return 'INSERT INTO Expenses SET ?';
};
Expand Down

0 comments on commit 182b2a1

Please sign in to comment.