ReactJS,MeteorJS和MongoDB:从不同的集合值中获取集合?

时间:2017-03-13 19:37:39

标签: mongodb reactjs meteor

好的,所以,我有一个带有函数getPhotos()的组件,它从父道具中获取一个字符串:

import React, { Component, PropTypes } from 'react';

// data
import { Cats } from '../api/collections/galleries.js';

export default class...
 getPhotos() {
   let gallery = this.props.galleryName; // gallery = "Cats"

现在,我想使用这个字符串“Cats”从mongo db访问一个集合,所以我尝试使用window [“Cats”],但我不认为它在窗口对象上:

   let photoData = window[gallery].find().fetch(); // window[Cats] and window["Cats"] returns undefined
   return photoData;
}

流星中的一切似乎都在起作用,发布和订阅。

我是如何使用React组件做到这一点的?

1 个答案:

答案 0 :(得分:0)

你可以做到

Meteor.connection._stores[gallery]._getCollection().find().fetch();
相关问题