为什么我需要在路由器文件中导入集合?

时间:2018-02-15 17:12:06

标签: mongodb meteor iron-router

我用流星建立简单的网络,只是为了相互了解,我正在玩铁:路由器作为路由器。

"问题"我得到的是我的meteorapp / lib / routes.js我需要导入我的收集文件,该文件位于meteorapp / imports / ui / reservations.js中:

import { Meteor } from 'meteor/meteor';
import { Template } from 'meteor/templating';
//collection Reservations
import { Reservations } from '../api/reservations.js';
import './roomSchedule.html';

Template.roomSchedule.onCreated(function roomScheduleOnCreated() {
  Meteor.subscribe('reservations');
});


Template.roomSchedule.helpers({

  allHours() {

    return Reservations.find();
  },

});

否则我无法在模板中访问它,即使我在templage.js文件中导入了相同的行(不同的路径),如下所示:

user@laptop:~/Documents/meteorApps/mymeteorApp$ meteor list
blaze-html-templates   1.1.2  Compile HTML templates into reactive UI with Meteor Blaze
ecmascript             0.10.3* Compiler plugin that supports ES2015+ in all .js files
es5-shim               4.7.3  Shims and polyfills to improve ECMAScript 5 support
insecure               1.0.7  (For prototyping only) Allow all database writes from the client
iron:router            1.1.2  Routing specifically designed for Meteor
meteor-base            1.3.0  Packages that every Meteor app needs
mobile-experience      1.0.5  Packages for a great mobile user experience
mongo                  1.4.3  Adaptor for using MongoDB and Minimongo over DDP
reactive-var           1.0.11  Reactive variable
shell-server           0.3.1  Server-side component of the `meteor shell` command.
standard-minifier-css  1.4.1  Standard css minifier used with Meteor apps by default.
standard-minifier-js   2.3.2  Standard javascript minifiers used with Meteor apps by default.
tracker                1.1.3  Dependency tracker to allow reactive callbacks

我不知道这是否会有所帮助,流星列表输出:

-----------------------------------------
|    CODE     |    KEY    |    VALUE    |
-----------------------------------------
|   123456    |    name   |    Paul     |
|   123456    |   surname |    White    |
|   123456    |   nation  |   England   |
|   987654    |    name   |    Alan     |
|   987654    |   surname |    Ford     |
|   987654    |   nation  |   Ireland   |
-----------------------------------------

所以它有效......但不知道为什么......先谢谢大家。

阿克塞尔。

0 个答案:

没有答案