Estoy haciendo un sistema de seguimiento, este es el esquema.
const usersSchema = new mongoose.Schema({ username: { type: String, required: true, trim: true, minLength: [5, "Username needs to be at least 5 characters long "], maxLength: [15, "Username cannot be any longer than 15 characters"], unique: true, }, password: { type: String, required: true, minLength:[8, "Password needs to be at least 8 characters long" ] }, email: { type: String, required: true, unique: true, }, createdAt:{ type:Date, default:()=>Date.now() }, updatedAt:{ type:Date, immutable:true, default:()=>Date.now() }, followers:[{ type: mongoose.SchemaTypes.ObjectId, ref: 'User', default:null }], following:[{ type: mongoose.SchemaTypes.ObjectId, ref: 'User', default:null }] })así es como trato de renderizar la página con la información.
<table border="1px"> <th> S. No </th> <th>Username</th> <th>Followers</th> <th>Following</th> <th>Edit</th> <% data.allUser.forEach((item)=> { %> <tr> <td> <%= k++ %> </td> <td> <%= item.username %> </td> <td> <%= item.followers %> </td> <td> <%= item.following %> </td> <td> <form action="/follow/ <%= item._id%>" method="POST" > <button id="<%= item._id %>">Follow</button> </form> </td> <% }) %> <form action="/logout" method="post"> <button>Log out</button> </form>Obtengo todas las cosas correctas cuando se trata del nombre de usuario y los botones, pero solo obtengo las identificaciones de todos los usuarios en las siguientes columnas y seguidores y si trato de agregar. longitud al final me sale un error