node.js - 已解决: find({user: {user: admin}}) 不适用于 mongodb
问题描述
我创建了一个小 API,我希望在登录 API 时仅使用用户名恢复用户配置文件,我的 Schema 看起来像这样(我使用 Mongoose):
user : {
username: String,
password: String
}
但是当我尝试执行时:
const User = require('../models/User')
const mongoose = require("mongoose")
User.find({user: {username: "test"})
它不起作用!我试试这个:
User.find({_id: "id")
和作品!我不明白 !
请帮帮我 !
解决方案
推荐阅读
- android - 数据绑定 onClick 不起作用
- android - Appcelerator - Android:隐藏状态栏和导航栏
- dart - 如何在 MaterialDatePickerComponent 上将星期一设置为一周的第一天?
- javascript - 访问每个对象中的json对象
- java - itext 7生成多个pdf页面,页面中有5个部分:首页边距错误
- python - Python:来自具有经度和纬度的数据帧的 A* 路由
- antlr4 - Python ANTLR4 无关输入加标记删除
- php - 问题 - Google API 日历 - G Suite - 服务帐户 - PHP
- jdbc - HIVE JDBC 选项以允许由“;”分隔的多个查询
- postgresql - 序列增量如 2018AA000001、2018AB000001、2018AC000001