2013-11-18 18:21:15 +04:00
|
|
|
var db = {
|
|
|
|
posts: {
|
|
|
|
id: {type: 'increments', nullable: false, primary: true},
|
2014-09-10 08:06:24 +04:00
|
|
|
uuid: {type: 'string', maxlength: 36, nullable: false, validations: {isUUID: true}},
|
2013-11-18 18:21:15 +04:00
|
|
|
title: {type: 'string', maxlength: 150, nullable: false},
|
|
|
|
slug: {type: 'string', maxlength: 150, nullable: false, unique: true},
|
2014-01-15 17:29:23 +04:00
|
|
|
markdown: {type: 'text', maxlength: 16777215, fieldtype: 'medium', nullable: true},
|
|
|
|
html: {type: 'text', maxlength: 16777215, fieldtype: 'medium', nullable: true},
|
2013-11-18 18:21:15 +04:00
|
|
|
image: {type: 'text', maxlength: 2000, nullable: true},
|
2014-09-10 08:06:24 +04:00
|
|
|
featured: {type: 'bool', nullable: false, defaultTo: false, validations: {isIn: [[0, 1, false, true]]}},
|
|
|
|
page: {type: 'bool', nullable: false, defaultTo: false, validations: {isIn: [[0, 1, false, true]]}},
|
2013-11-18 18:21:15 +04:00
|
|
|
status: {type: 'string', maxlength: 150, nullable: false, defaultTo: 'draft'},
|
|
|
|
language: {type: 'string', maxlength: 6, nullable: false, defaultTo: 'en_US'},
|
|
|
|
meta_title: {type: 'string', maxlength: 150, nullable: true},
|
|
|
|
meta_description: {type: 'string', maxlength: 200, nullable: true},
|
|
|
|
author_id: {type: 'integer', nullable: false},
|
|
|
|
created_at: {type: 'dateTime', nullable: false},
|
|
|
|
created_by: {type: 'integer', nullable: false},
|
|
|
|
updated_at: {type: 'dateTime', nullable: true},
|
|
|
|
updated_by: {type: 'integer', nullable: true},
|
|
|
|
published_at: {type: 'dateTime', nullable: true},
|
|
|
|
published_by: {type: 'integer', nullable: true}
|
|
|
|
},
|
|
|
|
users: {
|
|
|
|
id: {type: 'increments', nullable: false, primary: true},
|
2014-09-10 08:06:24 +04:00
|
|
|
uuid: {type: 'string', maxlength: 36, nullable: false, validations: {isUUID: true}},
|
2014-06-12 19:25:55 +04:00
|
|
|
name: {type: 'string', maxlength: 150, nullable: false},
|
|
|
|
slug: {type: 'string', maxlength: 150, nullable: false, unique: true},
|
2013-11-18 18:21:15 +04:00
|
|
|
password: {type: 'string', maxlength: 60, nullable: false},
|
2014-09-10 08:06:24 +04:00
|
|
|
email: {type: 'string', maxlength: 254, nullable: false, unique: true, validations: {isEmail: true}},
|
2013-11-18 18:21:15 +04:00
|
|
|
image: {type: 'text', maxlength: 2000, nullable: true},
|
|
|
|
cover: {type: 'text', maxlength: 2000, nullable: true},
|
|
|
|
bio: {type: 'string', maxlength: 200, nullable: true},
|
2014-09-10 08:06:24 +04:00
|
|
|
website: {type: 'text', maxlength: 2000, nullable: true, validations: {isEmptyOrURL: true}},
|
2013-11-18 18:21:15 +04:00
|
|
|
location: {type: 'text', maxlength: 65535, nullable: true},
|
|
|
|
accessibility: {type: 'text', maxlength: 65535, nullable: true},
|
|
|
|
status: {type: 'string', maxlength: 150, nullable: false, defaultTo: 'active'},
|
|
|
|
language: {type: 'string', maxlength: 6, nullable: false, defaultTo: 'en_US'},
|
|
|
|
meta_title: {type: 'string', maxlength: 150, nullable: true},
|
|
|
|
meta_description: {type: 'string', maxlength: 200, nullable: true},
|
2015-07-11 21:56:17 +03:00
|
|
|
tour: {type: 'text', maxlength: 65535, nullable: true},
|
2013-11-18 18:21:15 +04:00
|
|
|
last_login: {type: 'dateTime', nullable: true},
|
|
|
|
created_at: {type: 'dateTime', nullable: false},
|
|
|
|
created_by: {type: 'integer', nullable: false},
|
|
|
|
updated_at: {type: 'dateTime', nullable: true},
|
|
|
|
updated_by: {type: 'integer', nullable: true}
|
|
|
|
},
|
|
|
|
roles: {
|
|
|
|
id: {type: 'increments', nullable: false, primary: true},
|
2014-09-10 08:06:24 +04:00
|
|
|
uuid: {type: 'string', maxlength: 36, nullable: false, validations: {isUUID: true}},
|
2013-11-18 18:21:15 +04:00
|
|
|
name: {type: 'string', maxlength: 150, nullable: false},
|
|
|
|
description: {type: 'string', maxlength: 200, nullable: true},
|
|
|
|
created_at: {type: 'dateTime', nullable: false},
|
|
|
|
created_by: {type: 'integer', nullable: false},
|
|
|
|
updated_at: {type: 'dateTime', nullable: true},
|
|
|
|
updated_by: {type: 'integer', nullable: true}
|
|
|
|
},
|
|
|
|
roles_users: {
|
|
|
|
id: {type: 'increments', nullable: false, primary: true},
|
|
|
|
role_id: {type: 'integer', nullable: false},
|
|
|
|
user_id: {type: 'integer', nullable: false}
|
|
|
|
},
|
|
|
|
permissions: {
|
|
|
|
id: {type: 'increments', nullable: false, primary: true},
|
2014-09-10 08:06:24 +04:00
|
|
|
uuid: {type: 'string', maxlength: 36, nullable: false, validations: {isUUID: true}},
|
2013-11-18 18:21:15 +04:00
|
|
|
name: {type: 'string', maxlength: 150, nullable: false},
|
|
|
|
object_type: {type: 'string', maxlength: 150, nullable: false},
|
|
|
|
action_type: {type: 'string', maxlength: 150, nullable: false},
|
|
|
|
object_id: {type: 'integer', nullable: true},
|
|
|
|
created_at: {type: 'dateTime', nullable: false},
|
|
|
|
created_by: {type: 'integer', nullable: false},
|
|
|
|
updated_at: {type: 'dateTime', nullable: true},
|
|
|
|
updated_by: {type: 'integer', nullable: true}
|
|
|
|
},
|
|
|
|
permissions_users: {
|
|
|
|
id: {type: 'increments', nullable: false, primary: true},
|
|
|
|
user_id: {type: 'integer', nullable: false},
|
|
|
|
permission_id: {type: 'integer', nullable: false}
|
|
|
|
},
|
|
|
|
permissions_roles: {
|
|
|
|
id: {type: 'increments', nullable: false, primary: true},
|
|
|
|
role_id: {type: 'integer', nullable: false},
|
|
|
|
permission_id: {type: 'integer', nullable: false}
|
|
|
|
},
|
2014-02-12 07:40:39 +04:00
|
|
|
permissions_apps: {
|
|
|
|
id: {type: 'increments', nullable: false, primary: true},
|
|
|
|
app_id: {type: 'integer', nullable: false},
|
|
|
|
permission_id: {type: 'integer', nullable: false}
|
|
|
|
},
|
2013-11-18 18:21:15 +04:00
|
|
|
settings: {
|
|
|
|
id: {type: 'increments', nullable: false, primary: true},
|
2014-09-10 08:06:24 +04:00
|
|
|
uuid: {type: 'string', maxlength: 36, nullable: false, validations: {isUUID: true}},
|
2013-11-18 18:21:15 +04:00
|
|
|
key: {type: 'string', maxlength: 150, nullable: false, unique: true},
|
|
|
|
value: {type: 'text', maxlength: 65535, nullable: true},
|
2015-08-24 14:43:26 +03:00
|
|
|
type: {type: 'string', maxlength: 150, nullable: false, defaultTo: 'core', validations: {isIn: [['core', 'blog', 'theme', 'app', 'plugin', 'private']]}},
|
2013-11-18 18:21:15 +04:00
|
|
|
created_at: {type: 'dateTime', nullable: false},
|
|
|
|
created_by: {type: 'integer', nullable: false},
|
|
|
|
updated_at: {type: 'dateTime', nullable: true},
|
|
|
|
updated_by: {type: 'integer', nullable: true}
|
|
|
|
},
|
|
|
|
tags: {
|
|
|
|
id: {type: 'increments', nullable: false, primary: true},
|
2014-09-10 08:06:24 +04:00
|
|
|
uuid: {type: 'string', maxlength: 36, nullable: false, validations: {isUUID: true}},
|
2015-08-24 17:32:05 +03:00
|
|
|
name: {type: 'string', maxlength: 150, nullable: false, validations: {matches: /^([^,]|$)/}},
|
2013-11-18 18:21:15 +04:00
|
|
|
slug: {type: 'string', maxlength: 150, nullable: false, unique: true},
|
|
|
|
description: {type: 'string', maxlength: 200, nullable: true},
|
2014-07-18 21:58:29 +04:00
|
|
|
image: {type: 'text', maxlength: 2000, nullable: true},
|
2014-09-10 08:06:24 +04:00
|
|
|
hidden: {type: 'bool', nullable: false, defaultTo: false, validations: {isIn: [[0, 1, false, true]]}},
|
2013-11-18 18:21:15 +04:00
|
|
|
parent_id: {type: 'integer', nullable: true},
|
|
|
|
meta_title: {type: 'string', maxlength: 150, nullable: true},
|
|
|
|
meta_description: {type: 'string', maxlength: 200, nullable: true},
|
|
|
|
created_at: {type: 'dateTime', nullable: false},
|
|
|
|
created_by: {type: 'integer', nullable: false},
|
|
|
|
updated_at: {type: 'dateTime', nullable: true},
|
|
|
|
updated_by: {type: 'integer', nullable: true}
|
|
|
|
},
|
|
|
|
posts_tags: {
|
|
|
|
id: {type: 'increments', nullable: false, primary: true},
|
2014-06-10 20:06:08 +04:00
|
|
|
post_id: {type: 'integer', nullable: false, unsigned: true, references: 'posts.id'},
|
2015-09-01 03:51:56 +03:00
|
|
|
tag_id: {type: 'integer', nullable: false, unsigned: true, references: 'tags.id'},
|
|
|
|
sort_order: {type: 'integer', nullable: false, unsigned: true, defaultTo: 0}
|
2014-02-12 07:40:39 +04:00
|
|
|
},
|
|
|
|
apps: {
|
|
|
|
id: {type: 'increments', nullable: false, primary: true},
|
2014-09-10 08:06:24 +04:00
|
|
|
uuid: {type: 'string', maxlength: 36, nullable: false, validations: {isUUID: true}},
|
2014-02-12 07:40:39 +04:00
|
|
|
name: {type: 'string', maxlength: 150, nullable: false, unique: true},
|
2014-03-07 20:15:43 +04:00
|
|
|
slug: {type: 'string', maxlength: 150, nullable: false, unique: true},
|
|
|
|
version: {type: 'string', maxlength: 150, nullable: false},
|
|
|
|
status: {type: 'string', maxlength: 150, nullable: false, defaultTo: 'inactive'},
|
2014-02-12 07:40:39 +04:00
|
|
|
created_at: {type: 'dateTime', nullable: false},
|
|
|
|
created_by: {type: 'integer', nullable: false},
|
|
|
|
updated_at: {type: 'dateTime', nullable: true},
|
|
|
|
updated_by: {type: 'integer', nullable: true}
|
2014-02-20 18:29:43 +04:00
|
|
|
},
|
|
|
|
app_settings: {
|
|
|
|
id: {type: 'increments', nullable: false, primary: true},
|
2014-09-10 08:06:24 +04:00
|
|
|
uuid: {type: 'string', maxlength: 36, nullable: false, validations: {isUUID: true}},
|
2014-02-20 18:29:43 +04:00
|
|
|
key: {type: 'string', maxlength: 150, nullable: false, unique: true},
|
|
|
|
value: {type: 'text', maxlength: 65535, nullable: true},
|
2014-06-10 20:06:08 +04:00
|
|
|
app_id: {type: 'integer', nullable: false, unsigned: true, references: 'apps.id'},
|
2014-02-20 18:29:43 +04:00
|
|
|
created_at: {type: 'dateTime', nullable: false},
|
|
|
|
created_by: {type: 'integer', nullable: false},
|
|
|
|
updated_at: {type: 'dateTime', nullable: true},
|
|
|
|
updated_by: {type: 'integer', nullable: true}
|
|
|
|
},
|
|
|
|
app_fields: {
|
|
|
|
id: {type: 'increments', nullable: false, primary: true},
|
2014-09-10 08:06:24 +04:00
|
|
|
uuid: {type: 'string', maxlength: 36, nullable: false, validations: {isUUID: true}},
|
2014-02-20 18:29:43 +04:00
|
|
|
key: {type: 'string', maxlength: 150, nullable: false},
|
|
|
|
value: {type: 'text', maxlength: 65535, nullable: true},
|
|
|
|
type: {type: 'string', maxlength: 150, nullable: false, defaultTo: 'html'},
|
2014-06-10 20:06:08 +04:00
|
|
|
app_id: {type: 'integer', nullable: false, unsigned: true, references: 'apps.id'},
|
2014-02-20 18:29:43 +04:00
|
|
|
relatable_id: {type: 'integer', nullable: false, unsigned: true},
|
|
|
|
relatable_type: {type: 'string', maxlength: 150, nullable: false, defaultTo: 'posts'},
|
2014-09-10 08:06:24 +04:00
|
|
|
active: {type: 'bool', nullable: false, defaultTo: true, validations: {isIn: [[0, 1, false, true]]}},
|
2014-02-20 18:29:43 +04:00
|
|
|
created_at: {type: 'dateTime', nullable: false},
|
|
|
|
created_by: {type: 'integer', nullable: false},
|
|
|
|
updated_at: {type: 'dateTime', nullable: true},
|
|
|
|
updated_by: {type: 'integer', nullable: true}
|
2014-06-30 16:58:10 +04:00
|
|
|
},
|
|
|
|
clients: {
|
|
|
|
id: {type: 'increments', nullable: false, primary: true},
|
|
|
|
uuid: {type: 'string', maxlength: 36, nullable: false},
|
|
|
|
name: {type: 'string', maxlength: 150, nullable: false, unique: true},
|
|
|
|
slug: {type: 'string', maxlength: 150, nullable: false, unique: true},
|
2015-08-18 16:05:25 +03:00
|
|
|
secret: {type: 'string', maxlength: 150, nullable: false},
|
2015-01-11 02:49:48 +03:00
|
|
|
redirection_uri: {type: 'string', maxlength: 2000, nullable: true},
|
|
|
|
logo: {type: 'string', maxlength: 2000, nullable: true},
|
|
|
|
status: {type: 'string', maxlength: 150, nullable: false, defaultTo: 'development'},
|
2015-08-18 16:05:25 +03:00
|
|
|
type: {type: 'string', maxlength: 150, nullable: false, defaultTo: 'ua'},
|
2015-01-11 02:49:48 +03:00
|
|
|
description: {type: 'string', maxlength: 200, nullable: true},
|
2014-06-30 16:58:10 +04:00
|
|
|
created_at: {type: 'dateTime', nullable: false},
|
|
|
|
created_by: {type: 'integer', nullable: false},
|
|
|
|
updated_at: {type: 'dateTime', nullable: true},
|
|
|
|
updated_by: {type: 'integer', nullable: true}
|
|
|
|
},
|
2015-08-18 16:05:25 +03:00
|
|
|
client_trusted_domains: {
|
|
|
|
id: {type: 'increments', nullable: false, primary: true},
|
|
|
|
uuid: {type: 'string', maxlength: 36, nullable: false},
|
|
|
|
client_id: {type: 'integer', nullable: false, unsigned: true, references: 'clients.id'},
|
|
|
|
trusted_domain: {type: 'string', maxlength: 2000, nullable: true}
|
|
|
|
},
|
2014-06-30 16:58:10 +04:00
|
|
|
accesstokens: {
|
|
|
|
id: {type: 'increments', nullable: false, primary: true},
|
|
|
|
token: {type: 'string', nullable: false, unique: true},
|
|
|
|
user_id: {type: 'integer', nullable: false, unsigned: true, references: 'users.id'},
|
|
|
|
client_id: {type: 'integer', nullable: false, unsigned: true, references: 'clients.id'},
|
|
|
|
expires: {type: 'bigInteger', nullable: false}
|
|
|
|
},
|
|
|
|
refreshtokens: {
|
|
|
|
id: {type: 'increments', nullable: false, primary: true},
|
|
|
|
token: {type: 'string', nullable: false, unique: true},
|
|
|
|
user_id: {type: 'integer', nullable: false, unsigned: true, references: 'users.id'},
|
|
|
|
client_id: {type: 'integer', nullable: false, unsigned: true, references: 'clients.id'},
|
|
|
|
expires: {type: 'bigInteger', nullable: false}
|
2013-11-18 18:21:15 +04:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2014-01-03 04:37:21 +04:00
|
|
|
function isPost(jsonData) {
|
2014-02-12 07:40:39 +04:00
|
|
|
return jsonData.hasOwnProperty('html') && jsonData.hasOwnProperty('markdown') &&
|
|
|
|
jsonData.hasOwnProperty('title') && jsonData.hasOwnProperty('slug');
|
2014-01-03 04:37:21 +04:00
|
|
|
}
|
|
|
|
|
2014-02-13 20:15:29 +04:00
|
|
|
function isTag(jsonData) {
|
2014-07-18 21:58:29 +04:00
|
|
|
return jsonData.hasOwnProperty('name') && jsonData.hasOwnProperty('slug') &&
|
2014-07-20 19:39:56 +04:00
|
|
|
jsonData.hasOwnProperty('description') && jsonData.hasOwnProperty('parent');
|
2014-02-13 20:15:29 +04:00
|
|
|
}
|
|
|
|
|
2014-07-20 20:41:59 +04:00
|
|
|
function isUser(jsonData) {
|
|
|
|
return jsonData.hasOwnProperty('bio') && jsonData.hasOwnProperty('website') &&
|
|
|
|
jsonData.hasOwnProperty('status') && jsonData.hasOwnProperty('location');
|
|
|
|
}
|
|
|
|
|
2015-01-28 08:57:19 +03:00
|
|
|
function isNav(jsonData) {
|
|
|
|
return jsonData.hasOwnProperty('label') && jsonData.hasOwnProperty('url') &&
|
|
|
|
jsonData.hasOwnProperty('slug') && jsonData.hasOwnProperty('current');
|
|
|
|
}
|
|
|
|
|
2014-01-03 04:37:21 +04:00
|
|
|
module.exports.tables = db;
|
|
|
|
module.exports.checks = {
|
2014-02-13 20:15:29 +04:00
|
|
|
isPost: isPost,
|
2014-07-20 20:41:59 +04:00
|
|
|
isTag: isTag,
|
2015-01-28 08:57:19 +03:00
|
|
|
isUser: isUser,
|
|
|
|
isNav: isNav
|
2014-03-02 05:01:55 +04:00
|
|
|
};
|