简体   繁体   English

流星集合文件夹结构

[英]Meteor collection folder structure

The official Meteor doc says: 官方Meteor医生说:

Collections/# <- definitions of collections and methods on them (could be models). 集合/#< - 集合和方法的定义(可以是模型)。

In my database I have a collection universities . 在我的数据库中,我有一个收藏universities So in my Collections folder I have university.js . 所以在我的Collections文件夹中我有university.js
How to implement methods on collection, for example find() ? 如何实现集合方法,例如find() I don't want to have all code in my index.js . 我不希望我的index.js包含所有代码。 I know I can have Meteor.methods and Meteor.call but that is for client - server invoke. 我知道我可以使用Meteor.methods和Meteor.call,但这是用于客户端 - 服务器调用。

Maybe create a function like this. 也许创建这样的功能。 on whatever folder you want /lib/collections could be an option. 在你想要的任何文件夹上/lib/collections可以是一个选项。

for example find() 例如find()

function findMethod(){
  return Collection.find();
}

and use it whatever you want. 并随心所欲地使用它。

var finde = findMethod();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM