Skip to content

Commit b4987c6

Browse files
committed
Complete implementation
1 parent a8793c6 commit b4987c6

18 files changed

+7682
-1
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
.env

.prettierignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package-lock.json
2+
package.json
3+
.gitignore
4+
node_modules

.prettierrc.json

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
# Book-api
1+
#

database.json

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"dev": {
3+
"driver": "pg",
4+
"host": "127.0.0.1",
5+
"database": "lagos_lgas",
6+
"user": "auto_user",
7+
"password": "admin04"
8+
},
9+
"test": {
10+
"driver": "pg",
11+
"host": "127.0.0.1",
12+
"database": "fantasy_worlds_test",
13+
"user": "test_user",
14+
"password": "password123"
15+
}
16+
}
17+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
'use strict';
2+
3+
var dbm;
4+
var type;
5+
var seed;
6+
var fs = require('fs');
7+
var path = require('path');
8+
var Promise;
9+
10+
/**
11+
* We receive the dbmigrate dependency from dbmigrate initially.
12+
* This enables us to not have to rely on NODE_PATH.
13+
*/
14+
exports.setup = function(options, seedLink) {
15+
dbm = options.dbmigrate;
16+
type = dbm.dataType;
17+
seed = seedLink;
18+
Promise = options.Promise;
19+
};
20+
21+
exports.up = function(db) {
22+
var filePath = path.join(__dirname, 'sqls', '20220408165522-mythical-weapons-table-up.sql');
23+
return new Promise( function( resolve, reject ) {
24+
fs.readFile(filePath, {encoding: 'utf-8'}, function(err,data){
25+
if (err) return reject(err);
26+
console.log('received data: ' + data);
27+
28+
resolve(data);
29+
});
30+
})
31+
.then(function(data) {
32+
return db.runSql(data);
33+
});
34+
};
35+
36+
exports.down = function(db) {
37+
var filePath = path.join(__dirname, 'sqls', '20220408165522-mythical-weapons-table-down.sql');
38+
return new Promise( function( resolve, reject ) {
39+
fs.readFile(filePath, {encoding: 'utf-8'}, function(err,data){
40+
if (err) return reject(err);
41+
console.log('received data: ' + data);
42+
43+
resolve(data);
44+
});
45+
})
46+
.then(function(data) {
47+
return db.runSql(data);
48+
});
49+
};
50+
51+
exports._meta = {
52+
"version": 1
53+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
DROP TABLE district_area;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
CREATE TABLE district_area (
2+
title VARCHAR(250),
3+
author VARCHAR(250),
4+
total_pages integer,
5+
summary VARCHAR(250),
6+
id SERIAL PRIMARY KEY
7+
);

0 commit comments

Comments
 (0)