Circuit table...

This commit is contained in:
paoloar77
2022-08-26 03:33:13 +02:00
parent 5dfcd4f7fa
commit a2019c6ac9
5 changed files with 234 additions and 10 deletions

View File

@@ -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};