Mongodb 可以直接在meteor shell上调用服务器端方法吗?
我设置了一个集合“条目”,并定义了meteor服务器端方法:Mongodb 可以直接在meteor shell上调用服务器端方法吗?,mongodb,meteor,Mongodb,Meteor,我设置了一个集合“条目”,并定义了meteor服务器端方法: import { Meteor } from 'meteor/meteor'; import { Mongo } from 'meteor/mongo'; import { check } from 'meteor/check'; export const Entries = new Mongo.Collection('entries'); if (Meteor.isServer) { // This code only
import { Meteor } from 'meteor/meteor';
import { Mongo } from 'meteor/mongo';
import { check } from 'meteor/check';
export const Entries = new Mongo.Collection('entries');
if (Meteor.isServer) {
// This code only runs on the server
Meteor.publish('entries', function entriesPublication() {
return Entries.find({$or: [
{ id_user: this.userId },
],});
});
}
Meteor.methods({
'entries.setPosition'(entryId, position) {
check(entryId, String);
check(position, Number);
Entries.update(entryId, { $set: { position: position } });
});
是否可以使用不同的参数调用meteor或mongo shell中的entries.setPosition()并查看结果?我希望避免直接在控制台上重写或粘贴整个mongo查询(这会弄乱格式)。执行函数后如何查看受影响的行?是的,您可以这样做,就像从客户端调用一样。为什么不使用节点调试器?