Skip to content

Commit

Permalink
async transform in cacheField, fix for collection-hooks changes _hook…
Browse files Browse the repository at this point in the history
…Aspects -> _hooks
  • Loading branch information
Bero committed Nov 9, 2024
1 parent 0de629e commit 3552fa9
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
meteor: [3.0.1]
meteor: [3.0.4]

steps:
- uses: actions/checkout@v4
Expand Down
8 changes: 4 additions & 4 deletions cacheField.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Mongo.Collection.prototype.cacheField = async function (options) {

async function insertHook(userid, doc) {
await collection.updateAsync(doc._id, {
$set: { [cacheField]: transform(_.pick(doc, fields)) },
$set: { [cacheField]: await transform(_.pick(doc, fields)) },
});
}

Expand All @@ -41,9 +41,9 @@ Mongo.Collection.prototype.cacheField = async function (options) {

collection.after.update((userId, doc, changedFields) => {
if (_.intersection(changedFields, topFields).length) {
Meteor.defer(() => {
collection.updateAsync(doc._id, {
$set: { [cacheField]: transform(_.pick(doc, fields)) },
Meteor.defer(async () => {
await collection.updateAsync(doc._id, {
$set: { [cacheField]: await transform(_.pick(doc, fields)) },
});
});
}
Expand Down
2 changes: 1 addition & 1 deletion package.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Package.onTest(function (api) {
'ecmascript',
'mongo',
'check',
'matb33:collection-hooks@2.0.0-rc.2',
'matb33:collection-hooks@2.0.0-rc.4',
]);

api.use(['meteortesting:mocha']);
Expand Down
12 changes: 6 additions & 6 deletions tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ describe('setup', function () {
it('clear hooks', function () {
//Remove all collection hooks so that migration tests work properly
_.each([Posts, Comments, Users, Images, Tags, Likes], (collection) => {
collection._hookAspects.insert.after = [];
collection._hookAspects.update.after = [];
collection._hookAspects.remove.after = [];
collection._hooks.insert.after = [];
collection._hooks.update.after = [];
collection._hooks.remove.after = [];
});
});
it('insert migrants', async function () {
Expand Down Expand Up @@ -1479,9 +1479,9 @@ describe('Recursive caching', function () {
});
it('clear hooks', function () {
_.each([Customers, Bills, Items], (collection) => {
collection._hookAspects.insert.after = [];
collection._hookAspects.update.after = [];
collection._hookAspects.remove.after = [];
collection._hooks.insert.after = [];
collection._hooks.update.after = [];
collection._hooks.remove.after = [];
});
});
it('set up caches', function () {
Expand Down

0 comments on commit 3552fa9

Please sign in to comment.