简体   繁体   English

WebStorm自动完成Mongoose模式字段

[英]WebStorm to autocomplete Mongoose schema fields

Let's say I'm using the standard Mongoose model: 假设我使用的是标准的Mongoose模型:

Creating a schema 创建模式

const userSchema    = new mongoose.Schema({
  displayName     : {type: String, required: true},
  phoneNumber     : {type: String},
});

Then connect it to a model: 然后将其连接到模型:

const UserModel = mongooseClient.model('User', userSchema);

I'd like WebStorm to autocomplete me in the following way: 我希望WebStorm通过以下方式自动完成:

const myUser = new UserModel();
myUser.disp // should suggest 'displayName'

How do I accomplish it? 我该如何完成?

Providing completion for your schema fields/methods requires adding special support for Mongooze, as objects generated in runtime can't be resolved by static code analysis. 为架构字段/方法提供完成要求需要添加对Mongooze的特殊支持,因为在运行时生成的对象无法通过静态代码分析来解决。 We have a feature request for this, please feel free to vote: WEB-22317 . 我们对此有功能要求,请随时投票: WEB-22317

For now, using JSDoc to annotate objects is the only way to go 目前,使用JSDoc注释对象是唯一的方法

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM