Code Monkey home page Code Monkey logo

Comments (5)

tarlepp avatar tarlepp commented on August 21, 2024

Sails.js itself doesn't support cascade delete but you can manage that part by yourself eg. http://stackoverflow.com/questions/22462065/sails-js-waterline-orm-removing-data-from-multiply-models

from angular-sailsjs-boilerplate.

jjgonver avatar jjgonver commented on August 21, 2024

Well. Before I put my question casually I had read that question in stackoverflow. My doubt was that how to make delete cascading in your frontend with the same syntax. For example:

        // Scope function to delete Survey
        $scope.deleteSurvey = function deleteSurvey() {
          SurveyModel
            .delete($scope.survey.id)
            .then(
              function onSuccess() {
                //After delete a Survey we must delete their Answer
                AnswerModel
                .delete({survey: $scope.survey.id})
                .then(
                  function onSuccess(result) {
                    answersId = _.map(result, function(answers) {return answers.id;});
                    VoteModel
                    .delete({answer: answersId})
                  }
                )
                MessageService.success('Survey "' + $scope.survey.question + '" delete.');

                $state.go('survey.dashboard');
              }
            )
          ;
        };

Does this code make sense? Should this code work?
A lot of thanks for your help and your patience.

from angular-sailsjs-boilerplate.

tarlepp avatar tarlepp commented on August 21, 2024

Personally I would do this all logic on backend side and not in the frontend side code. Eg you could use model lifecycle callbacks to handle all those cascade deletes http://sailsjs.org/documentation/concepts/models-and-orm/lifecycle-callbacks

from angular-sailsjs-boilerplate.

jjgonver avatar jjgonver commented on August 21, 2024

Thanks for show me the correct way.

from angular-sailsjs-boilerplate.

jjgonver avatar jjgonver commented on August 21, 2024

By the way. I made you a private question by Gitter - Sails (@jjgonver) that is not an issue about your boilerplate. Would you be so kind as to take a look? Thanks

from angular-sailsjs-boilerplate.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.