Javascript 将值推送到sails.js集合

Javascript 将值推送到sails.js集合,javascript,angularjs,node.js,sails.js,waterline,Javascript,Angularjs,Node.js,Sails.js,Waterline,我在sails.js的一个小项目中工作,我有两个模型:Empresa和Noticia,Empresa模型有Noticia集合,Noticia模型有Empresa关系: Empresa.js module.exports = { attributes: { nombre: { type: 'string' }, activa:{ type: 'boolean', defaultsTo: false }, usua

我在sails.js的一个小项目中工作,我有两个模型:Empresa和Noticia,Empresa模型有Noticia集合,Noticia模型有Empresa关系:

Empresa.js

module.exports = {

  attributes: {
    nombre: {
        type: 'string'
    },
    activa:{
      type: 'boolean',
      defaultsTo: false
    },
    usuarios:{
      collection: 'User',
      via: 'empresa'
    },
    noticias:{
      collection: 'Noticia',
      via: 'empresa'
    }
  }
};
Noticia.js

module.exports = {

  attributes: {
    titulo:{
        type: 'string',
        required: true
    },
    texto:{
        type: 'string',
        required: true
    },
    publicada:{
      type: 'boolean',
      defaultsTo: false
    },
    empresa:{
      model: 'Empresa',
      via: 'noticias'
    }
  }
在前端,我有一个angular应用程序,它将一个接一个地将Notifias添加到Notifias集合中,我该怎么做

EmpresaNotificias angular.js控制器

.controller('EmpresaUsuarioController', function ($scope, $routeParams, $location, Noticia, Empresa) {

    $scope.addNoticia = function(){
        $scope.newNoticia.empresa = $routeParams.EmpresaId;
        Noticia.save($scope.newNoticia, function(noticia){
            Empresa.update({id: $routeParams.EmpresaId}, {noticias: noticia.id}, function(){
                $location.path('/noticia/'+ noticia.id);
            })
        }, function(error){
            console.log(error);
        });
    };

});

我知道javascript中存在向数组添加值的函数push,我想在sails.js中做类似的事情,谢谢,这是一个愚蠢的回答,D:我只需要稍微更改angular.js控件,如下所示:

.controller('EmpresaUsuarioController', function ($scope, $routeParams, $location, Noticia, Empresa) {

    $scope.addNoticia = function(){
        $scope.newNoticia.empresa = $routeParams.EmpresaId;
        Noticia.save($scope.newNoticia, function(noticia){
           $location.path('/noticia/'+ noticia.id);
        }, function(error){
      });
    };
});