Skip to content
Snippets Groups Projects
Commit b4024e64 authored by Rodrigo Nascimento's avatar Rodrigo Nascimento
Browse files

Replace "new Meteor.Collection" by @_initModel in models

parent e4be2e45
No related branches found
No related tags found
No related merge requests found
......@@ -12,6 +12,7 @@ Package.onUse(function(api) {
api.use('reactive-dict');
api.use('coffeescript');
api.use('random');
api.use('check');
api.use('underscore');
api.use('underscorestring:underscore.string');
......
RocketChat.models.Messages = new class asd extends RocketChat.models._Base
constructor: ->
@model = new Meteor.Collection 'rocketchat_message'
@_initModel 'message'
@tryEnsureIndex { 'rid': 1, 'ts': 1 }
@tryEnsureIndex { 'ets': 1 }, { sparse: 1 }
......
RocketChat.models.Reports = new class asd extends RocketChat.models._Base
constructor: ->
@model = new Meteor.Collection 'rocketchat_reports'
@_initModel 'reports'
# INSERT
......
RocketChat.models.Rooms = new class asd extends RocketChat.models._Base
constructor: ->
@model = new Meteor.Collection 'rocketchat_room'
@_initModel 'room'
@tryEnsureIndex { 'name': 1 }, { unique: 1, sparse: 1 }
@tryEnsureIndex { 'u._id': 1 }
......
RocketChat.models.Subscriptions = new class asd extends RocketChat.models._Base
constructor: ->
@model = new Meteor.Collection 'rocketchat_subscription'
@_initModel 'subscription'
@tryEnsureIndex { 'rid': 1, 'u._id': 1 }, { unique: 1 }
@tryEnsureIndex { 'u._id': 1, 'name': 1, 't': 1 }, { unique: 1 }
......
RocketChat.models._Base = class
_baseName: ->
return 'rocketchat_'
_initModel: (name) ->
check name, String
@model = new Meteor.Collection @_baseName() + name
find: ->
return @model.find.apply @model, arguments
......
RocketChat.models.OEmbedCache = new class asd extends RocketChat.models._Base
constructor: ->
@model = new Meteor.Collection 'rocketchat_oembed_cache'
@_initModel 'oembed_cache'
# FIND ONE
......
RocketChat.models.MRStatistics = new class asd extends RocketChat.models._Base
constructor: ->
@model = new Meteor.Collection 'rocketchat_mr_statistics'
@_initModel 'mr_statistics'
# FIND ONE
findOneById: (_id, options) ->
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment