Mongodb Meteor集合作为Coffeescript类的静态成员

Mongodb Meteor集合作为Coffeescript类的静态成员,mongodb,meteor,coffeescript,Mongodb,Meteor,Coffeescript,嗯。我认为这将是构建我的下一个Meteor应用程序的一个好主意。我用咖啡笔迹/翡翠/触笔和流星组合 我的想法是这样做: class @Lorem @collection = new Mongo.Collection('lorem_ipsum') constructor: (@a, @b, @c, @d, @e) -> Lorem.collection.insert({a: 'test', b: 'test'}) # just an example, schemas would c

嗯。我认为这将是构建我的下一个Meteor应用程序的一个好主意。我用咖啡笔迹/翡翠/触笔和流星组合

我的想法是这样做:

class @Lorem
  @collection = new Mongo.Collection('lorem_ipsum')
  constructor: (@a, @b, @c, @d, @e) ->
Lorem.collection.insert({a: 'test', b: 'test'}) # just an example, schemas would come later on
这样我就可以通过
lorem=new-lorem
来创建结构化对象,或者通过
lorem.collection.find({})
来直接访问Mongo。当然,我想创建一层方法,如:

lorem = new Lorem
lorem.add() # for adding to collection
lorem.remove() # for removing from collection
# etc.
我已经开始收集了我可以这样做:

class @Lorem
  @collection = new Mongo.Collection('lorem_ipsum')
  constructor: (@a, @b, @c, @d, @e) ->
Lorem.collection.insert({a: 'test', b: 'test'}) # just an example, schemas would come later on

它是一个可行的代码结构吗?在Meteor(Coffeescript)中,有没有更好的方法来正确地结构化数据和对象?

我认为这是一种有趣的方法,但不适合stackoverflow,因为它完全基于观点。您可能想看看哪些实现了类似的功能。有关这种方法的讨论,请参阅。感谢您提供这些链接,尤其是天文学!它看起来有点像我想要建造的!没错,下次我会尽量避免问基于意见/主观的问题。