UNPKG

954 BJavaScriptView Raw
1"use strict";
2
3module.exports = function(sequelize, DataTypes) {
4 var Collaborators = sequelize.define("Collaborators", {
5 id: {
6 type: DataTypes.BIGINT(20),
7 allowNull: false,
8 autoIncrement: true,
9 primaryKey: true
10 },
11 appid: DataTypes.INTEGER(10),
12 uid: DataTypes.BIGINT(20),
13 roles : DataTypes.STRING,
14 created_at: DataTypes.DATE,
15 updated_at: DataTypes.DATE,
16 }, {
17 tableName: 'collaborators',
18 underscored: true,
19 paranoid: true
20 });
21 Collaborators.findByAppNameAndUid = function (uid, appName) {
22 var sql = "SELECT b.* FROM `apps` as a left join `collaborators` as b on (a.id = b.appid) where a.name= :appName and b.uid = :uid and a.`deleted_at` IS NULL and b.`deleted_at` IS NULL limit 0,1";
23 return sequelize.query(sql, { replacements: { appName: appName, uid: uid }, model: Collaborators})
24 .then(function(data) {
25 return data.pop();
26 });
27 };
28 return Collaborators;
29};