-
Notifications
You must be signed in to change notification settings - Fork 1
Usage
AGenson edited this page Mar 4, 2018
·
3 revisions
All the following configuration will be in this folder : ./src/fixtures/database_template/
database.config.js
module.exports = {
host: "mysql.example.host",
port: "3306", // Default for mysql => 3306
database: "db_example",
username: "db_user",
password: "db_password"
}
index.js
const Table1Model = require("./Table1Model");
const Table2Model = require("./Table2Model");
module.exports = {
Table1: Table1Model,
Table2: Table2Model
};
Table1Model.js
module.exports = {
name: "table1_elt",
define: {
id: { // id must always exist
type: Sequelize.UUID, // Uses uuidv4 by default (default value is recommended)
primaryKey: true,
defaultValue: Sequelize.UUIDV4
},
first: {
type: Sequelize.STRING(255),
allowNull: false,
unique: true,
defaultValue: "Default"
},
second: {
type: Sequelize.TEXT,
allowNull: false
},
third: {
type: Sequelize.DOUBLE,
allowNull: false
}
},
options: {
timestamps: false
}
};
- Change Filters to your need
- And add the tables you want for your service
"use strict";
const Database = require("../adapters/Database");
// Filters applied when searching for entities
// Elements correspond to the columns of the table
const Filters_T1 = {
full: ["id", "first", "second", "third"]
};
const Filters_T2 = {
full: ["id", "first", "second"]
};
module.exports = {
name: "service",
actions: { ... },
methods: { ... },
created() {
this.DB_Table1 = new Database("Table1", Filters_T1.full);
this.DB_Table2 = new Database("Table2"); // Default: Filters_T2.full
}
getAll: {
params: {
},
handler(ctx) {
return this.DB_Table1.find(ctx)
}
}
- Home
- Features
- Install
- Usage
-
Database Functions
- Constructor
- Operations
- Database Errors
- Account Management