Circuit table...
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
/*
|
||||
Account is a User's single Circuit
|
||||
*/
|
||||
const mongoose = require('mongoose').set('debug', false);
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
@@ -17,12 +20,15 @@ const AccountSchema = new Schema({
|
||||
_id: {
|
||||
type: Number,
|
||||
},
|
||||
circuitId: {
|
||||
type: Number,
|
||||
},
|
||||
userId: {
|
||||
idapp: {
|
||||
type: String,
|
||||
},
|
||||
username: {
|
||||
type: String,
|
||||
},
|
||||
circuitId: { // ----- REF TO Circuit
|
||||
type: Number,
|
||||
},
|
||||
name: {
|
||||
type: String,
|
||||
},
|
||||
@@ -38,11 +44,11 @@ const AccountSchema = new Schema({
|
||||
});
|
||||
|
||||
AccountSchema.statics.findAllIdApp = async function(idapp) {
|
||||
const MyAccount = this;
|
||||
const Account = this;
|
||||
|
||||
const myfind = {idapp};
|
||||
|
||||
return await MyAccount.find(myfind, (err, arrrec) => {
|
||||
return await Account.find(myfind, (err, arrrec) => {
|
||||
return arrrec;
|
||||
});
|
||||
};
|
||||
@@ -76,6 +82,22 @@ AccountSchema.statics.executeQueryTable = function(idapp, params) {
|
||||
return tools.executeQueryTable(this, 0, params);
|
||||
};
|
||||
|
||||
AccountSchema.statics.getAccountsByUsername = async function(idapp, username) {
|
||||
const Account = this;
|
||||
|
||||
if (username === undefined)
|
||||
return false;
|
||||
|
||||
const myquery = {
|
||||
'idapp': idapp,
|
||||
'username': username,
|
||||
};
|
||||
|
||||
return await Account.find(myquery);
|
||||
|
||||
};
|
||||
|
||||
|
||||
const Account = mongoose.model('Account', AccountSchema);
|
||||
|
||||
module.exports = {Account};
|
||||
|
||||
Reference in New Issue
Block a user