MongoDBにこういうデータがあります。
json
1{ 2 "name": "hoge様", 3 "pass": "hogehoge", 4 "id": "hogehoge", 5 "age": "20", 6 "profile": "学生です!w", 7 "friend": [ 8 "hoge1", 9 "hoge2", 10 "hoge3" 11 ], 12 "pin": { 13 "comment": "コメントです", 14 "ido": "1.1", 15 "keido": "2.2", 16 "date": "2016-08-19T18:25:45.663Z" 17 } 18}
pinの中のcommentでfindしたいのですが上手く行きません
javascript
1var Schema = mongoose.Schema; 2var userSchema = new Schema({ 3 id: String, 4 pass: String, 5 name: String, 6 age: String, 7 profile: String, 8 image: String, 9 friend: [], 10 pin:{ 11 comment: String, 12 ido: String, 13 keido: String, 14 date: String 15 } 16}, { 17 versionKey: false // You should be aware of the outcome after set to false 18}); 19var User = mongoose.model("users", userSchema); 20 21User.find( {pin: {comment:"コメントです"}} ,{id: 1,name: 1,pin: 1,_id: 0}, function( err, docs ){ 22 console.log(JSON.stringify(docs)); 23},this);
だれかやり方が分かる人いたら教えてください
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/08/20 00:33