This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// initial idea is taken here https://blog.andyet.com/2016/02/23/generating-shortids-in-postgres/ | |
// this version is more general as we can pass the name of the column while setting up the trigger | |
// can be even more general if we pass the number of random bytes as the second argument (different length of short urls) | |
module.exports = { | |
up: async (queryInterface, Sequelize) => [ | |
await queryInterface.sequelize.query('CREATE EXTENSION IF NOT EXISTS pgcrypto;'), | |
await queryInterface.sequelize.query('CREATE EXTENSION IF NOT EXISTS hstore;'), | |
await queryInterface.sequelize.query(` | |
-- Create a trigger function that takes no arguments. | |
-- Trigger functions automatically have OLD, NEW records |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE job ( | |
id SERIAL PRIMARY KEY, | |
alias VARCHAR(20) | |
); | |
CREATE TABLE container ( | |
id SERIAL PRIMARY KEY, | |
job INT REFERENCES job(id) ON DELETE CASCADE NOT NULL, | |
index INT NOT NULL, -- keep the order of containers | |
name VARCHAR(100) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
angular.module('app.api.entities.task', ['app.api.rest.task']) | |
.factory('Task', ['$rootScope', '$q', 'TaskApi', 'Socket', function($rootScope, $q, TaskApi, Socket) { | |
// here we use a simple in memory cache in order to keep actual data | |
// you can make it in any other way | |
var cache = {}; | |
var initObject = function(data) { | |
if (cache[data._id]) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
angular.module('app.api.entities.task', ['app.api.rest.task']) | |
.factory('Task', ['$rootScope', '$q', 'TaskApi', 'Socket', function($rootScope, $q, TaskApi, Socket) { | |
// here we use a simple in memory cache in order to keep actual data | |
// you can make it in any other way | |
var cache = {}; | |
var initObject = function(data) { | |
if (cache[data._id]) { |