小编Ric*_*ann的帖子

Mongodb排序内部数组

我一直在寻找一段时间,似乎无法对内部数组进行排序,并将其保留在我正在使用的文档中.

{
    "service": {
        "apps": {
            "updates": [
              {
                "n" : 1
                "date": ISODate("2012-03-10T16:15:00Z")
              },
              {
                "n" : 2
                "date": ISODate("2012-01-10T16:15:00Z")
              },
              {
                "n" : 5
                "date": ISODate("2012-07-10T16:15:00Z")
              }
            ]
        }
     }
 }
Run Code Online (Sandbox Code Playgroud)

所以我想保持项目作为服务返回,但我的更新数组已排序.到目前为止,我有shell:

db.servers.aggregate(
        {$unwind:'$service'},
        {$project:{'service.apps':1}},
        {$unwind:'$service.apps'}, 
        {$project: {'service.apps.updates':1}}, 
        {$sort:{'service.apps.updates.date':1}});
Run Code Online (Sandbox Code Playgroud)

有人认为他们可以提供帮助吗?

mongodb aggregation-framework

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

如何在zepto中使用requirejs

我似乎无法使用requirejs来使用zepto.

这是我的文件

main.js

require.config({
  paths: {
    zepto: 'libs/zepto/zepto.min',
    underscore: 'libs/underscore/underscore-min',
    backbone: 'libs/backbone/backbone-min',
    cordova: 'libs/cordova/cordova-2.1.0',
    history: 'libs/history/history',
    historyZ: 'libs/history/history.adapter.zepto'
  },
  shim: {
        zepto: {
          exports: '$'
        },
        backbone: {
            deps: ['underscore', 'zepto']
        }}
});

require([

  // Load our app module and pass it to our definition function
  'app',
], function(App){
  // The "app" dependency is passed in as "App"
  App.initialize();
});
Run Code Online (Sandbox Code Playgroud)

app.js

define([
  'zepto',
  'underscore',
  'backbone',
  'router' // Request router.js
], function($, _, Backbone, Router){
  var initialize = function(){
    // Pass …
Run Code Online (Sandbox Code Playgroud)

javascript frontend requirejs backbone.js zepto

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