summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorJules Laplace <jules@okfoc.us>2017-04-21 12:30:57 -0400
committerJules Laplace <jules@okfoc.us>2017-04-21 12:30:57 -0400
commit5028ad81845308f3b1954dcc1fde664077fa0fa9 (patch)
tree2e999beb6df2b3d8c4ccf70aa5a460c2374adb4b /db
parent4c8c80162a60231b0254abcce8a336447c3a3416 (diff)
scaffolding
Diffstat (limited to 'db')
-rw-r--r--db/bookshelf.js35
-rw-r--r--db/index.js26
2 files changed, 61 insertions, 0 deletions
diff --git a/db/bookshelf.js b/db/bookshelf.js
new file mode 100644
index 0000000..00a0614
--- /dev/null
+++ b/db/bookshelf.js
@@ -0,0 +1,35 @@
+re('knex')({
+ client: 'postgresql',
+ connection: {
+ host : process.env.DB_HOST,
+ user : process.env.DB_USER,
+ password : process.env.DB_PASS,
+ database : 'gogo',
+ charset : 'utf8'
+ }
+})
+
+var bookshelf = require('bookshelf')(knex)
+
+module.exports = {
+ bookshelf: bookshelf,
+ knex: knex,
+}
+var knex = require('knex')({
+ client: 'mysql',
+ connection: {
+ host : process.env.DB_HOST,
+ user : process.env.DB_USER,
+ password : process.env.DB_PASS,
+ database : process.env.DB_NAME,
+ charset : 'utf8'
+ }
+})
+
+var bookshelf = require('bookshelf')(knex)
+
+module.exports = {
+ bookshelf: bookshelf,
+ knex: knex,
+}
+
diff --git a/db/index.js b/db/index.js
new file mode 100644
index 0000000..6124e31
--- /dev/null
+++ b/db/index.js
@@ -0,0 +1,26 @@
+var db = module.exports
+
+var connection = require("./bookshelf")
+var bookshelf = connection.bookshelf
+var knex = connection.knex
+
+/* MODELS */
+
+var Customer = bookshelf.Model.extend({ tableName: 'cw_customers' })
+var OrderSKU = bookshelf.Model.extend({ tableName: 'cw_order_skus' })
+var Order = bookshelf.Model.extend({ tableName: 'cw_orders' })
+var Product = bookshelf.Model.extend({ tableName: 'cw_products' })
+var SKU = bookshelf.Model.extend({ tableName: 'cw_skus' })
+
+/* PICTURES */
+
+db.createUser = function(data){
+ return new db.User(data).save()
+}
+db.getUsers = function (callback) {
+ return User.query(function(qb){
+ qb.orderBy("id", "desc")
+ }).fetchAll()
+}
+
+