小编Wan*_*tal的帖子

在Node Sequelize中订购渴望加载模型的结果

我有一组复杂的关联模型.模型使用连接表关联,每个连接表都有一个名为"order"的属性.我需要能够查询父模型"页面"并包含关联的模型,并按字段"顺序"对这些关联进行排序.

以下对结果的排序顺序没有影响:

db.Page.findAll({
  include: [{
    model: db.Gallery,
    order: ['order', 'DESC'],
    include: [{
      model: db.Artwork,
      order: ['order', 'DESC']
    }]
  }],
})
Run Code Online (Sandbox Code Playgroud)

postgresql node.js sequelize.js

46
推荐指数
3
解决办法
2万
查看次数

将父范围值传递到Angular中的ng-repeat循环

这应该是一个非常简单的问题,但我发现的所有变通方法都很复杂.我在模板中使用ng-repeat循环遍历一组对象,如下所示:

<div class="row-fluid" ng-repeat="message in messages.current|filter:'draft'"> 
    {{ message.subject }} ... {{ campaign.name }} ...
</div>
Run Code Online (Sandbox Code Playgroud)

由于ng-repeat创建了一个新范围,因此来自控制器的"campaign"对象似乎不可访问.是否有任何方法(除了将运动对象添加到我的数组中的每个项目)获得该值?

提前致谢.

javascript angularjs angular-template

45
推荐指数
1
解决办法
6万
查看次数

使用Splunk监控AmazonS3日志?

我们有一个庞大的扩展用户网络,我们使用徽章进行跟踪.总流量每月接近6000万印象.我们目前正在考虑从一个相当慢的,基于数据库的日志记录解决方案(基于PHP-messy ...定制)转换为依赖于AmazonS3日志和Splunk的简单的基于日志的替代方案.

在使用Splunk进行其他一些分析任务后,我非常喜欢它.但目前尚不清楚如何在系统中设置S3这样的源代码.似乎远程源需要安装Universal Forwarder,这不是一个选项.

有什么想法吗?

amazon-s3 splunk amazon-web-services access-log

5
推荐指数
1
解决办法
2156
查看次数

使用服务AngularJS在两个控制器之间共享动态数据

我有两个角度服务,需要共享模型(消息列表和单个消息),他们从调用我们的API获得.服务如下:

angular.module('CmServices', ['ngResource'])
.factory('Messages', function ($resource, $routeParams, $rootScope) { 

    var data = {};

    data.rest = $resource(url, {}, {
            query: {method:'GET', params: params},
            post: {method:'POST', params: params}
        });

    // Trying to set this through a call to the API (needs to get param from route)
    $rootScope.$on('$routeChangeSuccess', function(event, current, previous) {
            var messages = data.rest.query({m_gid: $routeParams.gid}, function () { 
                data.messages = messages;
            });
    });

    return data;    
});
Run Code Online (Sandbox Code Playgroud)

和控制器是:

function MessagesCtrl ($scope, $http, $location, $routeParams, Messages) {
   $scope.messages = Messages.messages;
}

function MessageCtrl …
Run Code Online (Sandbox Code Playgroud)

javascript rest controller angularjs

2
推荐指数
1
解决办法
4289
查看次数

用户在Django中创建后更新用户配置文件

我通过添加自定义"配置文件"模型,然后在用户save/create上实例化,使用1.4x方法扩展了用户对象.在我的注册过程中,我想向配置文件模型添加其他信息.视图成功呈现,但配置文件模型不保存.代码如下:

    user = User.objects.create_user(request.POST['username'], request.POST['email'], request.POST['password'])
    user.save()

    profile = user.get_profile()
    profile.title = request.POST['title']
    profile.birthday = request.POST['birthday']

    profile.save()
Run Code Online (Sandbox Code Playgroud)

python django django-models django-views django-authentication

1
推荐指数
1
解决办法
3709
查看次数

Firebase设置方法无效

在Firebase中创建节点应用程序,并且在"设置"值时遇到很多麻烦.我有一种潜在的怀疑,这与权限或其他东西有关(我没有设置我自己的任何读/写权限),但不确定.简化代码如下:

var Firebase = require("firebase");
var Scope = new Firebase('https://my-firebase.firebaseio.com/');

Scope.child("users").child(queue.uid).on('value', function(user) {

    console.log(user.val()); // Works fine
    user.set({id: 123}); // Fails, "Object has no method 'set'"

});
Run Code Online (Sandbox Code Playgroud)

任何想法将不胜感激.

database node.js firebase

0
推荐指数
1
解决办法
2663
查看次数