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

mapAsync is not a function error while using #2

Open
vit0rr opened this issue Aug 23, 2023 · 3 comments
Open

mapAsync is not a function error while using #2

vit0rr opened this issue Aug 23, 2023 · 3 comments

Comments

@vit0rr
Copy link

vit0rr commented Aug 23, 2023

Hello,
I'm testing the script and ai got this error:

LOGS
 ERR ../.meteor/local/bundler-cache/scanner/web.browser.legacy/reify-5a065996604b2eb9ace1f983694e85102d619fcf.js Transformation error (rootCollection.find(...).mapAsync is not a function)
TypeError: rootCollection.find(...).mapAsync is not a function
    at module.exports (/Users/vitorsouza/Desktop/work/dashboard/jscodeshift/transform.ts:288:49)
 ERR ../.meteor/local/bundler-cache/scanner/web.browser.legacy/reify-5a455a810648bbea7c617121c3ede4b9702ccb8d.js Transformation error (rootCollection.find(...).mapAsync is not a function)
TypeError: rootCollection.find(...).mapAsync is not a function
    at module.exports (/Users/vitorsouza/Desktop/work/dashboard/jscodeshift/transform.ts:288:49)
 ERR ../.meteor/local/bundler-cache/scanner/web.browser.legacy/reify-4c4ac0ddb15ed59aaa59838c3bffd05e146260c1.js Transformation error (rootCollection.find(...).mapAsync is not a function)
TypeError: rootCollection.find(...).mapAsync is not a function
    at module.exports (/Users/vitorsouza/Desktop/work/dashboard/jscodeshift/transform.ts:288:49)
 ERR ../.meteor/local/bundler-cache/scanner/web.browser.legacy/reify-4c19c517a6fd8ec50813ce189e4c1446bdc22123.js Transformation error (rootCollection.find(...).mapAsync is not a function)
TypeError: rootCollection.find(...).mapAsync is not a function
    at module.exports (/Users/vitorsouza/Desktop/work/dashboard/jscodeshift/transform.ts:288:49)
 ERR ../.meteor/local/bundler-cache/scanner/web.browser.legacy/reify-4cd9149a10e9465400ab3117102bf969a79950d7.js Transformation error (rootCollection.find(...).mapAsync is not a function)
TypeError: rootCollection.find(...).mapAsync is not a function
    at module.exports (/Users/vitorsouza/Desktop/work/dashboard/jscodeshift/transform.ts:288:49)
 ERR ../.meteor/local/bundler-cache/scanner/web.browser.legacy/reify-56ce2ff9993ebbee7eaf1022b40bee1ea3aeb716.js Transformation error (rootCollection.find(...).mapAsync is not a function)
TypeError: rootCollection.find(...).mapAsync is not a function
    at module.exports (/Users/vitorsouza/Desktop/work/dashboard/jscodeshift/transform.ts:288:49)
@minhna
Copy link
Owner

minhna commented Aug 23, 2023

I think somehow you run the script against the transform file.
The original file at line 288, it's .map() not .mapAsync()
https://github.com/minhna/meteor-async-migration/blob/main/transform.ts#L288

@vit0rr
Copy link
Author

vit0rr commented Aug 23, 2023

@minhna I think that I know the problem.
My codebase does not declare a new collection using new Mongo.Collection('collection'). I need to add a case to validate it.

case "NewExpression": {
if (p6.value.init.callee.type === "MemberExpression") {
const { object, property } = p6.value.init.callee;
if (
object.type === "Identifier" &&
object.name === "Mongo" &&
property.type === "Identifier" &&
property.name === "Collection"
) {
result = true;
}
}
break;
}
case "MemberExpression": {
const { object, property } = p6.value.init;
if (
object.type === "Identifier" &&
object.name === "Meteor" &&
property.type === "Identifier" &&
property.name === "users"
) {
result = true;
}
}

@minhna
Copy link
Owner

minhna commented Aug 23, 2023

Yes, you can modify it to make it works with your code base.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants