Skip to content

constructor

AGenson edited this page Mar 4, 2018 · 2 revisions

Constructor

Property Type Default Description
table String required Name of the wanted table (defined in ./src/fixtures/database_template/models/index.js)
filter Array.<String> all columns Default filter for search (columns of the table)
  • It will verify that the table name exists
  • Filter not required: it will put a default one itself (all the columns)
  • If provided, the filter will be checked (columns from table)

Example

The constructor must always be called on the service creation.

You can create as many instance per service as you want.

"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: { ... },

	created() {
		this.DB_Table1 = new Database("Table1", Filters_T1.full);
		this.DB_Table2 = new Database("Table2"); // Default: Filters_T2.full
	}
Clone this wiki locally