使用最新的fethersjs和mongodb。
我使用猫鼬做了一个小featjs应用程序。它在我的笔记本电脑上运行良好我使用PM2在ubuntu 16.04上部署它。
使用feat客户端,我无法从数据库中检索任何数据,但实际上有30744500个文档。
使用API我找到记录(/ items):
{"total":30744500,"limit":100,"skip":0,"data": ...data..}
这是我/ public app.js摘要:
// Establish a Socket.io connection
const socket = io();
// Initialize our Feathers client application through Socket.io
// with hooks and authentication.
const client = feathers();
client.configure(feathers.socketio(socket));
// Use localStorage to store our login token
client.configure(feathers.authentication({
storage: window.localStorage
}));
query_obj = getQueryObj();
const events = await client.service('events').find(query_obj);
max_ = events.total;
console.log('total:'+max_);
events.data.forEach(addEvent);
...其中query_obj等于:
{ “查询”:{ “$排序”:{ “时间戳”: - 1}, “$极限”:100, “$跳过”:0}}
任何帮助都将不胜感激。
感谢。
编辑:
但是现在我在执行find命令时遇到了Timeout错误。 Chrome的控制台告诉我这个:
app.js:181 {"query":{"$sort":{"timestamp":-1},"$limit":100,"$skip":0}}
index.js:135 Uncaught (in promise) Timeout {type: "FeathersError", name: "Timeout", message: "Timeout of 5000ms exceeded calling find on events", code: 408, className: "timeout", …}className: "timeout"code: 408data: method: "find"path: "events"timeout: 5000__proto__: constructor: ƒ Object()hasOwnProperty: ƒ hasOwnProperty()isPrototypeOf: ƒ isPrototypeOf()propertyIsEnumerable: ƒ propertyIsEnumerable()toLocaleString: ƒ toLocaleString()toString: ƒ toString()valueOf: ƒ valueOf()__defineGetter__: ƒ __defineGetter__()__defineSetter__: ƒ __defineSetter__()__lookupGetter__: ƒ __lookupGetter__()__lookupSetter__: ƒ __lookupSetter__()get __proto__: ƒ __proto__()set __proto__: ƒ __proto__()errors: __proto__: Objectmessage: "Timeout of 5000ms exceeded calling find on events"name: "Timeout"type: "FeathersError"stack: "Timeout: Timeout of 5000ms exceeded calling find on events↵ at new Timeout (https://unpkg.com/@feathersjs/client@3.4.4/dist/feathers.js:1468:17)↵ at https://unpkg.com/@feathersjs/client@3.4.4/dist/feathers.js:2903:23"__proto__: FeathersErrorconstructor: ƒ Timeout(message, data)arguments: (...)caller: (...)length: 2name: "Timeout"prototype: FeathersErrorconstructor: ƒ Timeout(message, data)__proto__: Error__proto__: ƒ ()[[FunctionLocation]]: index.js:134[[Scopes]]: Scopes[3]__proto__: Errorconstructor: ƒ FeathersError(msg, name, code, className, data)toJSON: ƒ value()__proto__: Object
showLogViewer @ app.js:288
async function (async)
showLogViewer @ app.js:245
login @ app.js:318
async function (async)
login @ app.js:303
(anonymous) @ app.js:383