# chat-server **Repository Path**: liudeng/chat-server ## Basic Information - **Project Name**: chat-server - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2018-06-05 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README * 1.jwt验证登录 * 2.options请求处理 * 3.mongodb 索引 索引通常能够极大的提高查询的效率 mongoose中给字段添加索引的方法 * 1.通过在定义schema的时候配置,如: var animalSchema = new Schema({ name: String, type: String, tags: { type: [String], index: true } }) * 2.通过index方法添加索引,如给name和type字段添加索引(1和-1分别表示升序索引和降序索引) animalSchema.index({ name: 1, type: -1 }); 语法: Query.populate(path, [select], [model], [match], [options]) 参数: * path 类型: String 或 Object String 类型时,指定要填充的关联字段,要填充多个关联字段可以以空格分隔 Object类型时,就是把populate的参数封装到一个对象里 * select 类型:Object 或 String,可选,指定填充document中的哪些字段 Object 类型时,格式如:{name: 1, _id: 0 },为 0 表示不填充,为 1 时表示填充 String 类型时,格式如: "name -_id",用空格分隔字段,在字段名前加上 - 表示不填充 * model 类型: Model,指定关联字段的model,如果没有指定就会使用Schema的ref * match 类型: Object,指定附加的查询条件 * options 类型: Object,指定附加的其他查询选项,如排序以及条数限制