Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

242
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!