Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let usuarios = new Schema({
- nombre: {
- type: String,
- required: true
- }
- }, { timestamps: true })
- if (!usuarios.options.toObject) {
- usuarios.options.toObject = {}
- }
- usuarios.options.toObject.transform = (doc, usuario, options) => {
- let idString = usuario._id.toString()
- let longitud = idString.length
- usuario.idShort = idString.substring((longitud - 5), longitud)
- return usuario
- }
- try {
- res.json(await Usuarios.find(query))
- } catch (error) {
- next(error)
- }
- })
- [ { _id: 5cedb09bf795132cb47a467a,
- updatedAt: 2019-05-28T22:05:15.851Z,
- createdAt: 2019-05-28T22:05:15.851Z,
- nombre: null,
- __v: 0 },
- { _id: 5cedb09bf795132cb47a467b,
- updatedAt: 2019-05-28T22:05:15.880Z,
- createdAt: 2019-05-28T22:05:15.880Z,
- nombre: null,
- __v: 0 } ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement