小编ant*_*_ku的帖子

如何在 nestjs 中填充猫鼬引用?

我定义了一个人和故事模式:

    @Schema()
    export class Person extends Document {
      @Prop()
      name: string;
    }
    export const PersonSchema = SchemaFactory.createForClass(Person);
    
    
    @Schema()
    export class Story extends Document {
    
      @Prop()
      title: string;
    
      @Prop()
      author:  { type: MongooseSchema.Types.ObjectId , ref: 'Person' }
    
    }
    export const StorySchema = SchemaFactory.createForClass(Story);
Run Code Online (Sandbox Code Playgroud)

在我的服务中,我实现了保存和读取功能:

        async saveStory(){
        const newPerson = new this.personModel();
        newPerson.name  = 'Ian Fleming';
        await newPerson.save();
        const newStory  = new this.storyModel();
        newStory.title = 'Casino Royale';
        newStory.author = newPerson._id;
        await newStory.save();
      }
    
      async readStory(){
        const stories = await this.storyModel.
            findOne({ title: …
Run Code Online (Sandbox Code Playgroud)

mongoose mongoose-populate nestjs

7
推荐指数
2
解决办法
4991
查看次数

商店用品 6 | 克隆 CmsElement 并获取 null 作为数据

我尝试克隆内容元素image-sliderimage-gallery(两者都会出现错误)以扩展它们。首先,我注册了一个新的 CmsElement,就像原来的一样,只是将名称从 更改image-sliderimage-slider-example

import './component';
import './config';
import './preview';

Shopware.Service('cmsService').registerCmsElement({
    name: 'image-slider-example',
    label: 'sw-cms.elements.imageSlider.label',
    component: 'sw-cms-el-image-slider',
    configComponent: 'sw-cms-el-config-image-slider',
    previewComponent: 'sw-cms-el-preview-image-slider',
    defaultConfig: {
        sliderItems: {
            source: 'static',
            value: [],
            required: true,
            entity: {
                name: 'media'
            }
        },
        displayMode: {
            source: 'static',
            value: 'standard'
        },
        minHeight: {
            source: 'static',
            value: '300px'
        },
        verticalAlign: {
            source: 'static',
            value: null
        }
    },
    enrich: function enrich(elem, data) {
        if (Object.keys(data).length < 1) {
            return;
        }

        Object.keys(elem.config).forEach((configKey) …
Run Code Online (Sandbox Code Playgroud)

javascript symfony twig vue.js shopware

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

我如何在 Nest.js 代码中首先使用 graphql-type-json 标量

我已经 npm 安装了 graphql-type-json 和类型。我如何在代码优先的方法中使用它,其中 JSONObject 是下面示例中的标量。

import {Field, Int, InputType} from 'type-graphql';
import {Direction, MessageType} from '../interfaces/message.interface';

@InputType()
export class MessageInput {
    @Field()
    readonly to: string;

    @Field()
    readonly type: MessageType;

    @Field()
    readonly direction: Direction;

    @Field()
    readonly body: **JSONObject**;
}
Run Code Online (Sandbox Code Playgroud)

graphql nestjs

5
推荐指数
2
解决办法
1555
查看次数

警告:React 的未来版本将阻止 javascript

我从 gitlab 克隆了 repo 并安装了依赖项,然后当我yarn next dev从命令行输入时,我得到

index.js:1 Warning: A future version of React will block javascript: URLs as a security precaution. Use event handlers instead if you can. If you need to generate unsafe HTML try using dangerouslySetInnerHTML instead. React was passed "javascript:;" 
Run Code Online (Sandbox Code Playgroud)

错误。在浏览器中,我code 404在登陆页面上出错。出了什么问题,我无法克服。

reactjs redux next.js

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

为 M1 上的所有平台构建 Tauri

有没有办法在我的 macbook pro m1 上构建 Windows 和 Linux 版本的 Tauri?我已经尝试过了,--target只是在构建时出现错误。

yarn run v1.22.15
$ tauri build -t x86_64-pc-windows-msvc
   Compiling proc-macro2 v1.0.36
   Compiling unicode-xid v0.2.2
   Compiling syn v1.0.86
   Compiling libc v0.2.119
   Compiling cfg-if v1.0.0
   Compiling serde_derive v1.0.136
   Compiling serde v1.0.136
   Compiling ppv-lite86 v0.2.16
   Compiling siphasher v0.3.9
   Compiling getrandom v0.1.16
   Compiling winapi v0.3.9
error[E0463]: can't find crate for `core`
  |
  = note: the `x86_64-pc-windows-msvc` target may not be installed
  = help: consider downloading the target with `rustup target add x86_64-pc-windows-msvc` …
Run Code Online (Sandbox Code Playgroud)

apple-m1 tauri

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

找不到项目的匹配配置:react-native-gesture-handler:易耗配置均没有属性

我收到错误消息无法找到项目的匹配配置:react-native-gesture-handler:易用的配置都不具有attribute.in react native。

“ react-native-gesture-handler”:已将“ ^ 1.1.0”添加到项目中

我已经将这些包括在我的本地反应项目中:

"dependencies": {
    "react": "16.6.3",
    "react-native": "0.58.6",
    "react-native-gesture-handler": "^1.1.0",
    "react-navigation": "^3.3.2"
  },
  "devDependencies": {
    "babel-core": "7.0.0-bridge.0",
    "babel-jest": "24.6.0",
    "jest": "24.6.0",
    "metro-react-native-babel-preset": "0.53.1",
    "react-test-renderer": "16.6.3"
  },
  "jest": {
    "preset": "react-native"
  }
Run Code Online (Sandbox Code Playgroud)

无法在avd上安装应用。我想在android虚拟设备(avd)中运行此项目。

react-native

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

Nest.js GraphQL 字段解析器

我的问题更多的是如何实现这一点。我在文档中没有找到答案,所以问你);

例如:

  • 我有 2 个实体用户和博客;

  • 用户与博客是一对多关系;

  • 我对用户的查询如下所示:

query {
    me {
        firstName
        lastName
        blogs {
            title
            description
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

在 Nest.js 代码中我有解析器:

query {
    me {
        firstName
        lastName
        blogs {
            title
            description
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

但是如果我们尝试将查询更改为:

query {
    me {
        firstName
        lastName
        blogs {
            title
            description
            user {
                id
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

问题:我们可以将 ResolveField 委托给另一个解析器(例如 BlogResolver)吗?

graphql nestjs

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

HeadlessUI/vue:TypeError vue.defineComponent 不是函数

我尝试@headlessui/vue在我的nuxt项目中安装。

当我尝试使用它时:

<template>
  <Menu>
    <MenuItems>
      <MenuItem>Item</MenuItem>
    </MenuItems>
  </Menu>
</template>

<script lang="ts">
import Vue from 'vue'
import { Menu, MenuButton, MenuItems, MenuItem } from '@headlessui/vue'

export default Vue.extend({
  components: { Menu, MenuButton, MenuItems, MenuItem },
  data () {
    return {
      isScrolling: false
    }
  },
....
Run Code Online (Sandbox Code Playgroud)

编译时出现类型错误

TypeError
vue.defineComponent is not a function
Run Code Online (Sandbox Code Playgroud)

typescript vuejs2 nuxt.js tailwind-css

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

在嵌套对象中设置值

我尝试通过键将值设置到嵌套数组中。

我的对象看起来像

var Obj = {
  key1: {
    key2: value,
  }
}
Run Code Online (Sandbox Code Playgroud)

我尝试通过key1.key2喜欢设置 key1

const name = `key1.key2`

Obj[name] = value
Run Code Online (Sandbox Code Playgroud)

我知道我需要这样做,Obj['key1']['key2']但我只得到一个string看起来像key1.key2

javascript

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