0
をNodejs私はこのようなデータを取得していますマングースデータにアクセスする方法:これはコードです</p> <p>:
User.find({ Username: user }, function(err, found_user) {
console.log('user data'+ found_user);
if(found_user.length > 0){
console.log('inside found user');
var recordings = found_user.recordings;
console.log(recordings)
for (var singleRecords in recordings){
console.log("Single record :"+singleRecords);
if(!singleRecords.isPlayed){
console.log(singleRecords.playingUrl);
twiml.play(singleRecords.playingUrl);
found_user.recordings[singleRecords].isPlayed = true;
found_user.save(function (err) {
if(err)
throw err
});
}
}
}
そして、これが見つかりました。ユーザーの値である:
user data { Username: 'B',
__v: 2,
_id: 58ac15e4b4e1232f6f118ba3,
recordings:
[ { isPlayed: false,
playingUrl: 'http://localhost:8000/public/toplay/playing_file_1487672817599.mp3' },
{ isPlayed: false,
playingUrl: 'http://localhost:8000/public/toplay/playing_file_1487672827411.mp3' } ]
}
inside found user
で変数found_user。しかし、それは私にそれの中の任意のデータを与えていません。 found_user.Usernameのように未定義の値が返されます。 私はそのレコーディングアレイを変数の中に保存したいと思います。どのようにそれを行うにはどのようなアイデア?
私たちにあなたがしようとしているコードを表示してください? –
最初のログfound_userは 'console.log(found_user);'を使用して出力を表示します – nivas
@nivas更新された質問を参照してください –