Skip to content

Commit

Permalink
working on car model
Browse files Browse the repository at this point in the history
  • Loading branch information
maks112v committed Oct 1, 2022
1 parent 7e6e212 commit a582382
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 6,988 deletions.
24 changes: 16 additions & 8 deletions api/cars/cars-model.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
const db = require('../../data/db-config.js');

const getAll = () => {
// DO YOUR MAGIC
}
return db('cars');
};

const getById = (id) => {
return db('cars').where({ id }).first();
};

const getById = () => {
// DO YOUR MAGIC
}
const create = (car) => {
return db('cars').insert(car);
};

const create = () => {
// DO YOUR MAGIC
}
module.exports = {
getAll,
getById,
create,
};
Binary file added data/dealer.db3
Binary file not shown.
12 changes: 10 additions & 2 deletions data/migrations/01-make_cars_table.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
exports.up = function (knex) {
// DO YOUR MAGIC
return knex.schema.createTable('cars', (tbl) => {
tbl.increments();
tbl.text('vin', 128).unique().notNullable();
tbl.text('make', 128).notNullable();
tbl.text('model', 128).notNullable();
tbl.decimal('mileage').notNullable();
tbl.text('title', 128);
tbl.text('transmission', 128);
});
};

exports.down = function (knex) {
// DO YOUR MAGIC
return knex.schema.dropTableIfExists('cars');
};
Loading

0 comments on commit a582382

Please sign in to comment.