const express = require('express'); const path = require('path'); const CrudModule = require('klapi/base/CrudModule'); const OneToOne = require('klapi/base/OneToOne'); const RepositorySystem = require('klapi/systems/RepositorySystem'); const RoutingSystem = require('klapi/systems/RoutingSystem'); const Actions = require('klapi/systems/ActionSystem'); let CategoriesScheme = { fields: [ { key: "name", type: "string", unique: true, keyLength: 50 }, { key: "link", type: "text" }, { key: "quantity", type: "integer" } ] }; class CategoriesModule extends CrudModule { constructor(){ super('/categories', [1,0,1,1,0], 'Categories', '', ); this.repository = RepositorySystem.create('Categories', CategoriesScheme); this.setRepo(this.repository); // this.userAccountConnection = new OneToOne('Account', 'Users'); // Actions.on('postUsers', (user) => { // let acc = { // }; // return this.repository.insert(acc).returning('id') // .then((data) => { // if(data[0]) { // user[this.name+"_id"] = data[0]; // return user; // } else { // throw new Error("Cannot create Account for inserted user"); // } // }) // }); } } module.exports = CategoriesModule;