Skip to content

Commit

Permalink
Change all instances of Meteor.Collection for Mongo.Collection (#6410)
Browse files Browse the repository at this point in the history
* Change all instances of Meteor.Collection for Mongo.Collection
http://stackoverflow.com/questions/25756664/is-it-mongo-collection-or-meteor-collection

* Include api.use(‘mongo’) where it was missing
  • Loading branch information
marceloschmidt authored and rodrigok committed Mar 23, 2017
1 parent 5344047 commit f98507d
Show file tree
Hide file tree
Showing 26 changed files with 41 additions and 32 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
RocketChat.models.Roles = new Meteor.Collection('rocketchat_roles');
RocketChat.models.Roles = new Mongo.Collection('rocketchat_roles');

Object.assign(RocketChat.models.Roles, {
findUsersInRole(name, scope, options) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ Package.onUse(function(api) {
'reactive-var',
'less',
'rocketchat:lib',
'rocketchat:channel-settings'
'rocketchat:channel-settings',
'mongo'
]);

api.addFiles([
Expand Down
4 changes: 2 additions & 2 deletions packages/rocketchat-integrations/client/collections.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
this.ChatIntegrations = new Meteor.Collection('rocketchat_integrations');
this.ChatIntegrationHistory = new Meteor.Collection('rocketchat_integration_history');
this.ChatIntegrations = new Mongo.Collection('rocketchat_integrations');
this.ChatIntegrationHistory = new Mongo.Collection('rocketchat_integration_history');
1 change: 1 addition & 0 deletions packages/rocketchat-integrations/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Package.describe({
});

Package.onUse(function(api) {
api.use('mongo');
api.use('coffeescript');
api.use('underscore');
api.use('ecmascript');
Expand Down
2 changes: 1 addition & 1 deletion packages/rocketchat-lib/client/lib/cachedCollection.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class CachedCollection {
version = 6,
maxCacheTime = 60*60*24*30
}) {
this.collection = collection || new Meteor.Collection(null);
this.collection = collection || new Mongo.Collection(null);

this.ready = new ReactiveVar(false);
this.name = name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ describe 'rocketchat:lib Server | Models | Base', ->
it 'should provide a basename for collections', ->
expect(typeof this.obj._baseName()).toBe('string')

it 'should carry a Meteor.Collection object when initialized', ->
it 'should carry a Mongo.Collection object when initialized', ->
expect(this.obj.model).toBeFalsy()
expect(this.obj._initModel('carry')).toBeTruthy()
expect(typeof this.obj.model).toBe('object')

it 'should apply a basename to the Meteor.Collection created', ->
it 'should apply a basename to the Mongo.Collection created', ->
name = 'apply'
expect(this.obj._initModel(name)).toBeTruthy()
expect(this.obj.model._name).toBe(this.obj._baseName() + name)
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
@ChatMessage = new Meteor.Collection null
@Department = new Meteor.Collection null
@ChatMessage = new Mongo.Collection null
@Department = new Mongo.Collection null
2 changes: 1 addition & 1 deletion packages/rocketchat-logger/client/viewLogs.coffee
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@stdout = new Meteor.Collection 'stdout'
@stdout = new Mongo.Collection 'stdout'

Meteor.startup ->
RocketChat.AdminBox.addOption
Expand Down
2 changes: 1 addition & 1 deletion packages/rocketchat-logger/logger.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ Template.prototype.onCreated = wrapLifeCycle Template.prototype.onCreated, 'onCr
Template.prototype.onRendered = wrapLifeCycle Template.prototype.onRendered, 'onRendered', 'green'
Template.prototype.onDestroyed = wrapLifeCycle Template.prototype.onDestroyed, 'onDestroyed', 'red'

# stdout = new Meteor.Collection 'stdout'
# stdout = new Mongo.Collection 'stdout'

# Meteor.subscribe 'stdout'

Expand Down
1 change: 1 addition & 0 deletions packages/rocketchat-logger/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Package.describe({
});

Package.onUse(function(api) {
api.use('mongo');
api.use('ecmascript');
api.use('coffeescript');
api.use('underscore');
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
@MentionedMessage = new Meteor.Collection 'rocketchat_mentioned_message'
@MentionedMessage = new Mongo.Collection 'rocketchat_mentioned_message'
1 change: 1 addition & 0 deletions packages/rocketchat-mentions-flextab/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Package.describe({

Package.onUse(function(api) {
api.use([
'mongo',
'ecmascript',
'coffeescript',
'underscore',
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
@PinnedMessage = new Meteor.Collection 'rocketchat_pinned_message'
@PinnedMessage = new Mongo.Collection 'rocketchat_pinned_message'
1 change: 1 addition & 0 deletions packages/rocketchat-message-pin/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Package.describe({

Package.onUse(function(api) {
api.use([
'mongo',
'coffeescript',
'ecmascript',
'underscore',
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
this.SnippetedMessages = new Meteor.Collection('rocketchat_snippeted_message');
this.SnippetedMessages = new Mongo.Collection('rocketchat_snippeted_message');
1 change: 1 addition & 0 deletions packages/rocketchat-message-snippet/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Package.describe({

Package.onUse(function(api) {
api.use([
'mongo',
'ecmascript',
'rocketchat:lib',
'rocketchat:file',
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
@StarredMessage = new Meteor.Collection 'rocketchat_starred_message'
@StarredMessage = new Mongo.Collection 'rocketchat_starred_message'
1 change: 1 addition & 0 deletions packages/rocketchat-message-star/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Package.describe({

Package.onUse(function(api) {
api.use([
'mongo',
'coffeescript',
'ecmascript',
'underscore',
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
@ChatOAuthApps = new Meteor.Collection 'rocketchat_oauth_apps'
@ChatOAuthApps = new Mongo.Collection 'rocketchat_oauth_apps'
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# @ChatOAuthApps = new Meteor.Collection 'rocketchat_oauth_apps'
# @ChatOAuthApps = new Mongo.Collection 'rocketchat_oauth_apps'

FlowRouter.route '/oauth/authorize',
action: (params, queryParams) ->
Expand Down
1 change: 1 addition & 0 deletions packages/rocketchat-oauth2-server-config/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Package.describe({
Package.onUse(function(api) {
api.use('webapp');
api.use('coffeescript');
api.use('mongo');
api.use('ecmascript');
api.use('rocketchat:lib');
api.use('rocketchat:api');
Expand Down
2 changes: 1 addition & 1 deletion packages/rocketchat-ui-admin/client/admin.coffee
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import toastr from 'toastr'
TempSettings = new Meteor.Collection null
TempSettings = new Mongo.Collection null
RocketChat.TempSettings = TempSettings

getDefaultSetting = (settingId) ->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@AdminChatRoom = new Meteor.Collection('rocketchat_room')
@AdminChatRoom = new Mongo.Collection('rocketchat_room')

Template.adminRooms.helpers
isReady: ->
Expand Down
1 change: 1 addition & 0 deletions packages/rocketchat-ui-admin/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Package.describe({

Package.onUse(function(api) {
api.use([
'mongo',
'ecmascript',
'templating',
'coffeescript',
Expand Down
10 changes: 5 additions & 5 deletions server/startup/migrations/v009.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@ RocketChat.Migrations.add({
// source collection is dropped after data migration
const toMigrate = [
{
source: new Meteor.Collection('data.ChatRoom'),
source: new Mongo.Collection('data.ChatRoom'),
target: RocketChat.models.Rooms.model
}, {
source: new Meteor.Collection('data.ChatSubscription'),
source: new Mongo.Collection('data.ChatSubscription'),
target: RocketChat.models.Subscriptions.model
}, {
source: new Meteor.Collection('data.ChatMessage'),
source: new Mongo.Collection('data.ChatMessage'),
target: RocketChat.models.Messages.model
}, {
source: new Meteor.Collection('settings'),
source: new Mongo.Collection('settings'),
target: RocketChat.models.Settings.model
}, {
// this collection may not exit
source: new Meteor.Collection('oembed_cache'),
source: new Mongo.Collection('oembed_cache'),
target: RocketChat.models.OEmbedCache.model
}
];
Expand Down
16 changes: 8 additions & 8 deletions server/startup/migrations/v015.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ RocketChat.Migrations.add({
version: 15,
up() {
console.log('Starting file migration');
const oldFilesCollection = new Meteor.Collection('cfs.Files.filerecord');
const oldGridFSCollection = new Meteor.Collection('cfs_gridfs.files.files');
const oldChunkCollection = new Meteor.Collection('cfs_gridfs.files.chunks');
const oldFilesCollection = new Mongo.Collection('cfs.Files.filerecord');
const oldGridFSCollection = new Mongo.Collection('cfs_gridfs.files.files');
const oldChunkCollection = new Mongo.Collection('cfs_gridfs.files.chunks');
const newFilesCollection = RocketChat.models.Uploads;
const newGridFSCollection = new Meteor.Collection('rocketchat_uploads.files');
const newChunkCollection = new Meteor.Collection('rocketchat_uploads.chunks');
const newGridFSCollection = new Mongo.Collection('rocketchat_uploads.files');
const newChunkCollection = new Mongo.Collection('rocketchat_uploads.chunks');

oldFilesCollection.find({
'copies.files.key': {
Expand Down Expand Up @@ -42,7 +42,7 @@ RocketChat.Migrations.add({
newFilesCollection.insert(record);

const oldGridFsFile = oldGridFSCollection.findOne({
_id: new Meteor.Collection.ObjectID(cfsRecord.copies.files.key)
_id: new Mongo.Collection.ObjectID(cfsRecord.copies.files.key)
});

newGridFSCollection.insert({
Expand All @@ -58,7 +58,7 @@ RocketChat.Migrations.add({
});

oldChunkCollection.find({
files_id: new Meteor.Collection.ObjectID(cfsRecord.copies.files.key)
files_id: new Mongo.Collection.ObjectID(cfsRecord.copies.files.key)
}).forEach((oldChunk) => {
newChunkCollection.insert({
_id: oldChunk._id,
Expand Down Expand Up @@ -96,7 +96,7 @@ RocketChat.Migrations.add({

oldFilesCollection.remove({_id: cfsRecord._id});
oldGridFSCollection.remove({_id: oldGridFsFile._id});
oldChunkCollection.remove({files_id: new Meteor.Collection.ObjectID(cfsRecord.copies.files.key)});
oldChunkCollection.remove({files_id: new Mongo.Collection.ObjectID(cfsRecord.copies.files.key)});
});

return console.log('End of file migration');
Expand Down

0 comments on commit f98507d

Please sign in to comment.