小编Min*_*ero的帖子

从 $arrayElemAt 结果中选择字段

$arrayElemAt内部选择特定字段$map。我只想选择从对象返回的名称字段$arrayElemAt

const data = await this.aggregate([
    {
      $match: { provider_id: providerId },
    },
    {
      $lookup: {
        from: 'users',
        localField: 'staff.user_id',
        foreignField: '_id',
        as: 'staffUsers',
      },
    },
    {
      $project: {
        staff: {
          $map: {
            input: '$staff',
            in: {
              _id: '$$this._id',
              email_login: '$$this.email_login',
              full_calendar_view: '$$this.full_calendar_view',
              verified: '$$this.verified',
              user_id: '$$this.user_id',
              description: '$$this.description',
              name: {
                $arrayElemAt: [
                  '$staffUsers',
                  {
                    $indexOfArray: ['$staffUsers._id', '$$this.user_id'],
                  },
                ],
              },
            },
          },
        },
      },
    },
  ]);
Run Code Online (Sandbox Code Playgroud)

javascript mongoose mongodb mongodb-query aggregation-framework

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

Ionic4 本机页面转换不适用于路由器导航

导航到新 url 时,页面转换不起作用。

我已经尝试了所有导航 ionic angular 的可能性routerLink href router.navigateByUrl()。我也尝试过 NativePageTransition 插件。

app.component.html:

<ion-app>
  <ion-content>
      <ion-router-outlet></ion-router-outlet>
      <ion-tabs>
        <ion-tab-bar slot="bottom">
          <ion-tab-button
            *ngFor="let tab of tabs"
            [attr.tab]="tab.action ? null : tab.path"
            (click)="tab.action ? handleTabClick(tab) : null">
            <ion-label>{{ tab.name }}</ion-label>
            <ion-icon [name]="tab.icon"></ion-icon>
          </ion-tab-button>
        </ion-tab-bar>
      </ion-tabs>
  </ion-content>
</ion-app>
Run Code Online (Sandbox Code Playgroud)

app-routing.module.ts:

import { NgModule } from '@angular/core';
import { PreloadAllModules, RouterModule, Routes } from '@angular/router';

const routes: Routes = [
  { path: '', redirectTo: 'explore', pathMatch: 'full' },
  { path: 'explore', loadChildren: './explore/explore.module#ExplorePageModule' },
  { …
Run Code Online (Sandbox Code Playgroud)

ionic-framework angular ionic4

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