小编Eri*_*cky的帖子

没有找到苗条课.我不确定这里做错了什么

这是我的索引文件的代码,它位于根目录中:

<?php
require 'vendor/autoload.php';
date_default_timezone_set('Asia/Seoul');

//$log = new Monolog\Logger('name');
//$log->pushHandler(new Monolog\Handler\StreamHandler('app.txt', Monolog\Logger::WARNING));
//$log->addWarning('Oh Noes.');

$app = new \Slim\Slim( array(
  'view' => new \Slim\Views\Twig()
));
$app->add(new \Slim\Middleware\SessionCookie());

$view = $app->view();
$view->parserOptions = array(
    'debug' => true
);
$view->parserExtensions = array(
    new \Slim\Views\TwigExtension(),
);
//Path To Our View
$app->view->setTemplatesDirectory("app/view");

// Configs for mode "production"
$app->configureMode('production', function () use ($app) {
    // Set the configs for production environment
    $app->config(array(
        'debug' => false,
        'database' => array(
            'db_host' => 'localhost',
            'db_port' => '',
            'db_name' => …
Run Code Online (Sandbox Code Playgroud)

php slim

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

如何按布尔值订购 firebase 查询

我的 firestore 文档中有一个布尔字段。我想按布尔值订购集合。与文档answer逻辑真与文档之前应该出现answer布尔值false。

   const item: AngularFirestoreCollection<any> =
       this.afs.collection(`items`,
          (ref) => ref.where('questionId', '==', questionId)
                      .orderBy('updatedAt', 'desc')
                      .orderBy('answer'));
   return item.valueChanges();
Run Code Online (Sandbox Code Playgroud)

firestore中的物品按以下顺序排列

items = {[
 {
id: 1,
questionId: x1,
answer: false,
updatedAt: 848939
},
{
id: 2,
questionId: x2,
answer: false,
updatedAt: 848936
},
{
id: 3,
questionId: x3,
answer: true,
updatedAt: 848938
}
]}
Run Code Online (Sandbox Code Playgroud)

查询完成后,我希望第三项位于索引 0...结果中的第一项。现在我只得到orderedBy updatedAt。

上面的查询没有给我上面要求的结果。我如何进行这样的查询?

javascript firebase angularfire google-cloud-firestore

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

如何按数组字段值javascript对数组进行排序

我有以下数组:

var objs = [ 
    { id: 'X82ns', name: 'james', presence: 'online'     },
    { id: '8YSHJ',    name: 'mary', presence: 'offline'   },
    { id: '7XHSK', name: 'rene', presence: 'online' }
];
Run Code Online (Sandbox Code Playgroud)

我想对数组进行排序,以便它通过'presence'返回一个新数组:'online'用户首先在离线项目之前显示.

所以如果排序,它应该返回这样的东西:

var objs = [ 
    { id: 'X82ns', name: 'james', presence: 'online' },
    { id: '7XHSK', name: 'rene', presence: 'online' },
    { id: '8YSHJ',    name: 'mary', presence: 'offline' }
];
Run Code Online (Sandbox Code Playgroud)

像这样的东西:

const newArray = objs.sort((a, b) => {
      if (a.presence === 'online') {
        return 1;
      } else if (b.presence …
Run Code Online (Sandbox Code Playgroud)

javascript

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