Extend database with more tables, rewrite API doc, improve API endpoints
This commit is contained in:
@@ -3,12 +3,18 @@ import { Order } from '../models/order.model'
|
||||
import { OrderItem } from '../models/orderItem.model'
|
||||
import { Product } from '../models/product.model'
|
||||
import { Account } from '../models/account.model'
|
||||
import { Address } from '../models/address.model'
|
||||
import { Payment } from '../models/payment.model'
|
||||
import { AccountRole } from '../models/accountRole.model'
|
||||
import { Brand } from '../models/brand.model'
|
||||
|
||||
import categories from "./../data/categories.json"
|
||||
import products from "./../data/products.json"
|
||||
import accounts from "./../data/accounts.json"
|
||||
import orders from "./../data/orders.json"
|
||||
import orderItems from "./../data/orderItems.json"
|
||||
import accountRoles from "./../data/accountRoles.json"
|
||||
import brands from "./../data/brands.json"
|
||||
|
||||
/**
|
||||
* Delete all datasets in every database table
|
||||
@@ -24,10 +30,22 @@ export function deleteAllTables() {
|
||||
/**
|
||||
* Insert default datasets in the database tables
|
||||
*/
|
||||
export function prepopulateDatabase() {
|
||||
export async function prepopulateDatabase() {
|
||||
AccountRole.bulkCreate(accountRoles.data)
|
||||
|
||||
// Account & Sub tables
|
||||
for (let account of accounts.data) {
|
||||
await Account.create(account)
|
||||
.then(dataset => {
|
||||
Address.bulkCreate(account.addresses)
|
||||
Payment.bulkCreate(account.payments)
|
||||
})
|
||||
}
|
||||
|
||||
Category.bulkCreate(categories.data)
|
||||
Brand.bulkCreate(brands.data)
|
||||
Product.bulkCreate(products.data)
|
||||
Account.bulkCreate(accounts.data)
|
||||
|
||||
Order.bulkCreate(orders.data)
|
||||
OrderItem.bulkCreate(orderItems.data)
|
||||
}
|
||||
Reference in New Issue
Block a user