Circuits OK
Accounts Ok Movements OK
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG);
|
||||
const mongoose = require('mongoose').set('debug', false);
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
mongoose.Promise = global.Promise;
|
||||
@@ -17,7 +17,10 @@ mongoose.plugin(schema => {
|
||||
|
||||
const CircuitSchema = new Schema({
|
||||
_id: {
|
||||
type: Number,
|
||||
type: String,
|
||||
default: function () {
|
||||
return new ObjectID().toString()
|
||||
}
|
||||
},
|
||||
idapp: {
|
||||
type: String,
|
||||
@@ -165,16 +168,7 @@ const CircuitSchema = new Schema({
|
||||
|
||||
CircuitSchema.pre('save', async function(next) {
|
||||
if (this.isNew) {
|
||||
const myrec = await Circuit.findOne().limit(1).sort({_id: -1});
|
||||
if (!!myrec) {
|
||||
if (myrec._doc._id === 0)
|
||||
this._id = 1;
|
||||
else
|
||||
this._id = myrec._doc._id + 1;
|
||||
|
||||
} else {
|
||||
this._id = 1;
|
||||
}
|
||||
this._id = new ObjectID().toString();
|
||||
|
||||
this.date_created = new Date();
|
||||
}
|
||||
@@ -210,7 +204,7 @@ CircuitSchema.statics.executeQueryTable = function(idapp, params) {
|
||||
CircuitSchema.statics.getWhatToShow = function(idapp, username) {
|
||||
// FOR ME, PERMIT ALL
|
||||
return {
|
||||
circuitId: 1,
|
||||
_id: 1,
|
||||
groupnameId: 1,
|
||||
path: 1,
|
||||
name: 1,
|
||||
@@ -245,7 +239,6 @@ CircuitSchema.statics.removeAdminOfMyCircuit = async function(idapp, username, n
|
||||
|
||||
CircuitSchema.statics.getWhatToShow_Unknown = function(idapp, username) {
|
||||
return {
|
||||
circuitId: 1,
|
||||
groupnameId: 1,
|
||||
path: 1,
|
||||
name: 1,
|
||||
@@ -271,7 +264,7 @@ CircuitSchema.statics.getWhatToShow_Unknown = function(idapp, username) {
|
||||
};
|
||||
};
|
||||
|
||||
CircuitSchema.statics.getCircuitsByUsername = async function(idapp, username, req) {
|
||||
CircuitSchema.statics.getCircuitsByUsername = async function(idapp, username, user) {
|
||||
|
||||
try {
|
||||
const {User} = require('../models/user');
|
||||
@@ -327,7 +320,7 @@ CircuitSchema.statics.getCircuitsByUsername = async function(idapp, username, re
|
||||
asked_circuits,
|
||||
refused_circuits,
|
||||
manage_mycircuits,
|
||||
mycircuits: req.user.profile.mycircuits,
|
||||
mycircuits: user.profile.mycircuits,
|
||||
};
|
||||
|
||||
} catch (e) {
|
||||
@@ -381,7 +374,7 @@ CircuitSchema.statics.getCircuitByName = async function(idapp, name) {
|
||||
CircuitSchema.statics.getCircuitById = async function(circuitId) {
|
||||
|
||||
const myfind = {
|
||||
circuitId,
|
||||
_id: circuitId,
|
||||
};
|
||||
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user