【问题标题】:findOne returns Object instead of DocumentfindOne 返回 Object 而不是 Document
【发布时间】:2016-03-08 10:44:42
【问题描述】:

线索和客户都是集合。为什么Leads.findOne() 返回一个对象?它应该像Customers.findOne() 那样返回一个文档。

我正在使用 Meteor 1.2.1。

【问题讨论】:

  • 这取决于您的类型的定义,因为如果不发布一些代码就无法指定。
  • 您是出于好奇而询问,还是类型差异导致了问题?
  • 我所有的findOne()s 返回对象。我不记得曾经看过Document。这就是网页本身的类型!

标签: javascript meteor collections


【解决方案1】:

这是因为集合 Customers 已通过 _transform 方法转换,而集合 Leads 没有。

参见documentation中Mongo.Collection的transform参数。

您很可能正在使用dburles:collection-helpers 包,它会自动添加transform。

【讨论】:

    猜你喜欢
    • 2018-05-24
    • 1970-01-01
    • 1970-01-01
    • 2017-04-11
    • 2021-10-04
    • 2019-10-18
    • 1970-01-01
    • 1970-01-01
    • 2012-10-13
    相关资源
    最近更新 更多