Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migration for compatibility with Meteor 3.0 #40

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 13 additions & 15 deletions .github/workflows/testsuite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: setup node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 16
node-version: 20

- name: cache dependencies
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-node-16-${{ hashFiles('**/package-lock.json') }}
key: ${{ runner.os }}-node-20-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-16-
${{ runner.os }}-node-20-

- run: cd test-proxy && npm ci && npm run setup && npm run lint

Expand All @@ -36,30 +36,28 @@ jobs:
strategy:
matrix:
meteorRelease:
- '2.3'
- '2.8.0'
- '2.14'
- '3.0-rc.2'
# Latest version
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 16
node-version: 20

- name: Setup meteor ${{ matrix.meteorRelease }}
uses: meteorengineer/setup-meteor@v1
with:
meteor-release: ${{ matrix.meteorRelease }}

- name: cache dependencies
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-node-16-${{ hashFiles('**/package-lock.json') }}
key: ${{ runner.os }}-node-20-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-16-
${{ runner.os }}-node-20-

- run: cd test-proxy && npm ci && npm run setup && npm run test
36 changes: 18 additions & 18 deletions .versions
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
accounts-base@2.2.9
accounts-base@2.2.11
allow-deny@1.1.1
babel-compiler@7.10.5
babel-runtime@1.5.1
base64@1.0.12
binary-heap@1.0.11
boilerplate-generator@1.7.2
callback-hook@1.5.1
check@1.3.2
dburles:mongo-collection-instances@0.4.0
check@1.4.1
dburles:mongo-collection-instances@1.0.0-rc300.1
ddp@1.4.1
ddp-client@2.6.1
ddp-common@1.4.0
ddp-client@2.6.2
ddp-common@1.4.1
ddp-rate-limiter@1.2.1
ddp-server@2.7.0
ddp-server@2.7.1
diff-sequence@1.1.2
dynamic-import@0.7.3
ecmascript@0.16.8
Expand All @@ -22,22 +22,22 @@ ecmascript-runtime-server@0.11.0
ejson@1.1.3
fetch@0.1.4
geojson-utils@1.0.11
http@1.0.10
http@1.0.1
id-map@1.1.1
inter-process-messaging@0.1.1
lai:collection-extensions@0.4.0
local-test:dburles:mongo-collection-instances@0.4.0
lai:collection-extensions@1.0.0-rc300.1
local-test:dburles:mongo-collection-instances@1.0.0-rc300.1
localstorage@1.2.0
logging@1.3.3
meteor@1.11.4
meteortesting:browser-tests@1.3.5
meteortesting:mocha@2.0.0
meteortesting:mocha-core@7.0.1
minimongo@1.9.3
logging@1.3.4
meteor@1.11.5
meteortesting:browser-tests@1.6.0-rc300.1
meteortesting:mocha@3.1.0-rc.1
meteortesting:mocha-core@8.3.1-rc300.1
minimongo@1.9.4
modern-browsers@0.1.10
modules@0.20.0
modules-runtime@0.13.1
mongo@1.16.8
mongo@1.16.10
mongo-decimal@0.1.3
mongo-dev-server@1.1.0
mongo-id@1.0.8
Expand All @@ -54,7 +54,7 @@ routepolicy@1.1.1
socket-stream-client@0.5.2
tracker@1.3.3
typescript@4.9.5
underscore@1.0.13
underscore@1.6.1
url@1.3.2
webapp@1.13.6
webapp@1.13.8
webapp-hashing@1.1.1
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@
[![Project Status: Active – The project has reached a stable, usable state and is being actively developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)
[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)

This package augments Mongo.Collection (and the deprecated Meteor.Collection) and allows you to later lookup a Mongo Collection instance by the collection name.

## Version 1.0.0 breaking changes!

This package augments Mongo.Collection (and the deprecated Meteor.Collection) and allows you to later lookup a Mongo Collection instance by the collection name.
> Beginning with version 1.0.0, this packages requires Meteor >= 3.0

Apart from that, everything else remains the same.

## Installation

Expand Down
6 changes: 3 additions & 3 deletions mongo-instances.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/* global CollectionExtensions */
import { Mongo } from 'meteor/mongo'
import { Meteor } from 'meteor/meteor'
import { CollectionExtensions } from 'meteor/lai:collection-extensions'
const instances = []

CollectionExtensions.addExtension(function (name, options) {
CollectionExtensions.addExtension(function mongoCollectionInstances (collection, name, options) {
instances.push({
name: name,
instance: this,
instance: collection,
options: options
})
})
Expand Down
18 changes: 11 additions & 7 deletions mongo-instances.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,35 @@ import { Meteor } from 'meteor/meteor'
const randomName = () => `test${Random.id(6)}`
const equal = (a, b) => expect(a).to.equal(b)

const insert = (collection, doc) => Meteor.isClient
? collection.insert(doc)
: collection.insertAsync(doc)

describe('unit tests', () => {
let collectionName

beforeEach(() => {
collectionName = randomName() // random ID, so a new collection every time
})

it('basic - works Mongo.Collection', () => {
it('basic - works Mongo.Collection', async () => {
const Test = new Mongo.Collection(collectionName)

Test.insert({ test: true })
await insert(Test, { test: true })
const find = Mongo.Collection.get(collectionName).find({ test: true })
equal(find.count(), 1)
equal(await find.countAsync(), 1)

// get an existing collection again
const ReGet = Mongo.Collection.get(collectionName)
equal(ReGet.find().count(), 1)
equal(await ReGet.find().countAsync(), 1)
})

it('basic - works Meteor.Collection', function () {
it('basic - works Meteor.Collection', async () => {
const Test = new Meteor.Collection(collectionName)
Test.insert({ test: true })
await insert(Test, { test: true })

const find = Meteor.Collection.get(collectionName).find({ test: true })
equal(find.count(), 1)
equal(await find.countAsync(), 1)
})

it('basic - collection already exists', () => {
Expand Down
12 changes: 6 additions & 6 deletions package.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,26 @@
Package.describe({
name: 'dburles:mongo-collection-instances',
summary: 'Access your Mongo instances',
version: '0.4.0',
version: '1.0.0-rc300.1',
git: 'https://github.com/dburles/mongo-collection-instances.git'
})

Package.onUse(function (api) {
api.versionsFrom(['1.0', '2.3', '2.8.0'])
api.versionsFrom(['2.3', '3.0-rc.4'])
api.use([
'mongo',
'ecmascript',
'lai:collection-extensions@0.4.0'])
'mongo',
'lai:collection-extensions@1.0.0-rc300.1'])
api.addFiles('mongo-instances.js')
})

Package.onTest(function (api) {
api.use([
'ecmascript',
'meteortesting:mocha@2.0.0',
'accounts-base',
'mongo',
'dburles:mongo-collection-instances'
'meteortesting:mocha@3.1.0-rc.1',
'dburles:mongo-collection-instances@1.0.0-rc300.1'
])
api.addFiles('mongo-instances.tests.js')
})
1 change: 1 addition & 0 deletions test-proxy-2x/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
19 changes: 19 additions & 0 deletions test-proxy-2x/.meteor/.finished-upgraders
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# This file contains information which helps Meteor properly upgrade your
# app when you run 'meteor update'. You should check it into version control
# with your project.

notices-for-0.9.0
notices-for-0.9.1
0.9.4-platform-file
notices-for-facebook-graph-api-2
1.2.0-standard-minifiers-package
1.2.0-meteor-platform-split
1.2.0-cordova-changes
1.2.0-breaking-changes
1.3.0-split-minifiers-package
1.4.0-remove-old-dev-bundle-link
1.4.1-add-shell-server-package
1.4.3-split-account-service-packages
1.5-add-dynamic-import-package
1.7-split-underscore-from-meteor-base
1.8.3-split-jquery-from-blaze
1 change: 1 addition & 0 deletions test-proxy-2x/.meteor/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
local
7 changes: 7 additions & 0 deletions test-proxy-2x/.meteor/.id
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# This file contains a token that is unique to your project.
# Check it into your repository along with the rest of this directory.
# It can be used for purposes such as:
# - ensuring you don't accidentally deploy one app on top of another
# - providing package authors with aggregated statistics

d0r7an81o8kin.vtm8cy3h9d9
23 changes: 23 additions & 0 deletions test-proxy-2x/.meteor/packages
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Meteor packages used by this project, one per line.
# Check this file (and the other files in this directory) into your repository.
#
# 'meteor add' and 'meteor remove' will edit this file for you,
# but you can also edit it by hand.

meteor-base@1.5.1 # Packages every Meteor app needs to have
mobile-experience@1.1.1 # Packages for a great mobile UX
mongo@1.16.8 # The database Meteor supports right now
static-html@1.3.2 # Define static page content in .html files
reactive-var@1.0.12 # Reactive variable for tracker
tracker@1.3.3 # Meteor's client-side reactive programming library

standard-minifier-css@1.9.2 # CSS minifier run for production mode
standard-minifier-js@2.8.1 # JS minifier run for production mode
es5-shim@4.8.0 # ECMAScript 5 compatibility for older browsers
ecmascript@0.16.8 # Enable ECMAScript2015+ syntax in app code
typescript@4.9.5 # Enable TypeScript syntax in .ts and .tsx modules
shell-server@0.5.0 # Server-side component of the `meteor shell` command

lai:collection-extensions@1.0.0-beta300.2
dburles:mongo-collection-instances@1.0.0-beta300.2
meteortesting:mocha@3.1.0-beta300.0
2 changes: 2 additions & 0 deletions test-proxy-2x/.meteor/platforms
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
server
browser
1 change: 1 addition & 0 deletions test-proxy-2x/.meteor/release
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
METEOR@2.15
70 changes: 70 additions & 0 deletions test-proxy-2x/.meteor/versions
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
allow-deny@1.1.1
autoupdate@1.8.0
babel-compiler@7.10.5
babel-runtime@1.5.1
base64@1.0.12
binary-heap@1.0.11
blaze-tools@1.1.3
boilerplate-generator@1.7.2
caching-compiler@1.2.2
caching-html-compiler@1.2.1
callback-hook@1.5.1
check@1.3.2
dburles:mongo-collection-instances@1.0.0-beta300.1
ddp@1.4.1
ddp-client@2.6.1
ddp-common@1.4.0
ddp-server@2.7.0
diff-sequence@1.1.2
dynamic-import@0.7.3
ecmascript@0.16.8
ecmascript-runtime@0.8.1
ecmascript-runtime-client@0.12.1
ecmascript-runtime-server@0.11.0
ejson@1.1.3
es5-shim@4.8.0
fetch@0.1.4
geojson-utils@1.0.11
hot-code-push@1.0.4
html-tools@1.1.3
htmljs@1.1.1
id-map@1.1.1
inter-process-messaging@0.1.1
lai:collection-extensions@1.0.0-beta300.1
launch-screen@2.0.0
logging@1.3.3
meteor@1.11.5
meteor-base@1.5.1
minifier-css@1.6.4
minifier-js@2.7.5
minimongo@1.9.3
mobile-experience@1.1.1
mobile-status-bar@1.1.0
modern-browsers@0.1.10
modules@0.20.0
modules-runtime@0.13.1
mongo@1.16.9
mongo-decimal@0.1.3
mongo-dev-server@1.1.0
mongo-id@1.0.8
npm-mongo@4.17.2
ordered-dict@1.1.0
promise@0.12.2
random@1.2.1
react-fast-refresh@0.2.8
reactive-var@1.0.12
reload@1.3.1
retry@1.1.0
routepolicy@1.1.1
shell-server@0.5.0
socket-stream-client@0.5.2
spacebars-compiler@1.3.1
standard-minifier-css@1.9.2
standard-minifier-js@2.8.1
static-html@1.3.2
templating-tools@1.2.2
tracker@1.3.3
typescript@4.9.5
underscore@1.6.1
webapp@1.13.8
webapp-hashing@1.1.1