Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

248
Vistas
How to customize default find, findOne, create and update actions in SailsJS?

I'm using SailJS to build a REST API. I've a lot of nested models, such as: A building has many Floors, which have many Apartments, which have an Owner.

The Sails populate implementation doesn't work as expected, and I can populate at max a single level nested model.

In order to make things work I would like to rewrite custom controllers like this: controllers/BuildingController.js

module.exports = {
  find: function (req, res) {
     // Custom code with population
  }
  findOne: function (req, res) {
     // Custom code with population
  }
  create: function (req, res) {
     // Custom code with nested object creation and connection to parent object
  }
  ...
}

If I call an endpoint through the blueprint my custom controller for that model is called, but if I call it from another point in the code (e.g. Apartment.find()) Sails use its default action, not mine.

Do you have some kind of hint or solution to this problem? Is this possible to implement?

Thanks in advance

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda