av一区二区在线观看_亚洲男人的天堂网站_日韩亚洲视频_在线成人免费_欧美日韩精品免费观看视频_久草视

您的位置:首頁(yè)技術(shù)文章
文章詳情頁(yè)

node.js - 使用mongoose的cursor的問(wèn)題

瀏覽:118日期:2024-07-25 17:58:39

問(wèn)題描述

自己測(cè)試過(guò)成功的樣例,自己新建了個(gè)集合插入了幾條數(shù)據(jù):

//testSchema.jsvar mongoose = require(’./db.js’), Schema = mongoose.Schema;var TestSchema = new Schema({ name: {type: String}, age: {type: Number}})var TestModel = mongoose.model(’stream’, TestSchema, ’stream’);var cache = [];var co = require(’co’);co(function*() { 'use strict'; const cursor = TestModel.find({}).cursor(); for (let doc = yield cursor.next(); doc != null; doc = yield cursor.next()) {console.log(doc); }});

node.js - 使用mongoose的cursor的問(wèn)題

數(shù)據(jù)是可以都拿到的

但是我去試自己爬蟲(chóng)爬到的數(shù)據(jù)集合,只取4條數(shù)據(jù)出來(lái),就有問(wèn)題:

//test.jsvar mongoose = require(’./db.js’), Schema = mongoose.Schema;var LagouSchema = new Schema({ name: {type: String}, cid: {type: Number}, process: {type: String}, content: {type: String}, url: {type: String}, tag: {type: String}, total: {type: Number}, salary: {type: Array}});var Lagou = mongoose.model(’lagou’, LagouSchema, ’lagou’);var co = require(’co’);co(function*() { 'use strict'; const cursor = Lagou.find({’cid’: {$gte:22777, $lte:22780}}).cursor(); for (let doc = yield cursor.next(); doc != null; doc = yield cursor.next()) {console.log(doc); }});

node.js - 使用mongoose的cursor的問(wèn)題

然后卡這兒就不會(huì)動(dòng)了,代碼都是一致的,怎么就取不出數(shù)據(jù)來(lái)呢,求解

問(wèn)題解答

回答1:

感覺(jué)你遇到的情況是cursor是空的。

檢查一下:

1、在mongo下面使用相同的條件查詢一下,看是否有返回的文檔。

相關(guān)文章:
主站蜘蛛池模板: 在线观看视频一区二区 | 成人在线视频网 | 毛片一级片 | 黄色片网站在线观看 | 国产精品一区二区三 | 欧美一级片在线 | 国产天天操 | 福利片在线观看 | 亚洲视频在线观看一区 | 亚洲精品久久久久 | 欧美日韩精品一区二区在线播放 | 国产理论在线观看 | 天天干视频 | 国产成人午夜 | 日韩视频免费看 | 亚洲欧美日本在线 | 国产精品美女久久 | 黄色亚洲| 六月激情 | 激情六月 | 欧美九九九 | 在线观看欧美日韩视频 | 久久一区二区视频 | www.操| 日本成人一区二区 | 天天射一射 | 在线一区视频 | 日韩精品视频在线免费观看 | 久久婷婷网 | 一级片黄色片 | 国产欧美日韩综合 | 日本一区二区三区四区五区 | 中文字幕精品在线观看 | 欧美精品色 | 久操福利视频 | 欧美日韩亚洲视频 | 伊人天堂网 | 欧美亚洲天堂 | 国产精品原创 | 久久精品99久久久久久 | 中国av在线播放 |