I have these relations: https://pastebin.com/hMZRJe0S
and I need to get the ui given the user
using java script I tried to get the id of usuario, then the ids of rol, then the ids of funcion and finally the ius. By getting the matching elements and then converting the ids into an array to get the elements of the next table(or collection)
fox example this is how i get the ids of rol:
const dbo = db.db("tareas");
dbo
.collection("usuario")
.find({ nombre: name, password })
.toArray(function(err, usuarios) {
console.log(2);
if (err) throw err;
console.log(usuarios);
if (usuarios.length > 0) {
var x;
dbo
.collection("usuario_rol")
.find({ "_id.id_usuario": usuarios[0]._id })
.toArray(function(err, usuarios_rol) {
if (err) throw err;
var idroles = [];
for (x = 0; x < usuarios_rol.length; x++) {
idroles.push(usuarios_rol[x]._id.id_rol);
}
then I get this "Topology was destroyed"
C:\Users\NORMA\Desktop\EXPRESS_CRASH_COURSE\node_modules\mongodb\lib\utils.js:132 throw err; ^
MongoError: Topology was destroyed at initializeCursor (C:\Users\NORMA\Desktop\EXPRESS_CRASH_COURSE\node_modules\mongodb-core\lib\cursor.js:596:25) at nextFunction (C:\Users\NORMA\Desktop\EXPRESS_CRASH_COURSE\node_modules\mongodb-core\lib\cursor.js:456:12) at Cursor.next (C:\Users\NORMA\Desktop\EXPRESS_CRASH_COURSE\node_modules\mongodb-core\lib\cursor.js:766:3) at Cursor._next (C:\Users\NORMA\Desktop\EXPRESS_CRASH_COURSE\node_modules\mongodb\lib\cursor.js:216:36) at fetchDocs (C:\Users\NORMA\Desktop\EXPRESS_CRASH_COURSE\node_modules\mongodb\lib\operations\cursor_ops.js:217:12) at toArray (C:\Users\NORMA\Desktop\EXPRESS_CRASH_COURSE\node_modules\mongodb\lib\operations\cursor_ops.js:247:3) at executeOperation (C:\Users\NORMA\Desktop\EXPRESS_CRASH_COURSE\node_modules\mongodb\lib\utils.js:416:24) at Cursor.toArray (C:\Users\NORMA\Desktop\EXPRESS_CRASH_COURSE\node_modules\mongodb\lib\cursor.js:829:10) at C:\Users\NORMA\Desktop\EXPRESS_CRASH_COURSE\routes\api\members.js:75:18 at result (C:\Users\NORMA\Desktop\EXPRESS_CRASH_COURSE\node_modules\mongodb\lib\utils.js:410:17) [nodemon] app crashed - waiting for file changes before starting...