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

fix: query option in gen2 sdks to correctly flatten the query object for mongodb #3250

Merged

Conversation

sidmohanty11
Copy link
Contributor

@sidmohanty11 sidmohanty11 commented Apr 30, 2024

Description

This PR updates the query option to use flattenMongoQuery which is basically flatten but when we get an $key we just return the object as is as, so that it properly gets parsed in our API (mongo query).

Jira
https://builder-io.atlassian.net/browse/ENG-5268

Loom
https://www.loom.com/share/10493e4fd2a24b40937590f7f690bff2

Fixes #3007

@sidmohanty11 sidmohanty11 requested review from samijaber and a team as code owners April 30, 2024 06:46
Copy link

changeset-bot bot commented Apr 30, 2024

🦋 Changeset detected

Latest commit: 2837f0d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 7 packages
Name Type
@builder.io/sdk-react-nextjs Patch
@builder.io/sdk-qwik Patch
@builder.io/sdk-react Patch
@builder.io/sdk-react-native Patch
@builder.io/sdk-solid Patch
@builder.io/sdk-svelte Patch
@builder.io/sdk-vue Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

vercel bot commented Apr 30, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
nextjs-app-router-example ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 1, 2024 4:35am
nextjs-pages-router-example ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 1, 2024 4:35am
remix-gen2-example ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 1, 2024 4:35am
svelte-vite-example ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 1, 2024 4:35am

Copy link

gitguardian bot commented Apr 30, 2024

⚠️ GitGuardian has uncovered 5 secrets following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

🔎 Detected hardcoded secrets in your pull request
GitGuardian id GitGuardian status Secret Commit Filename
314150 Triggered Generic High Entropy Secret 7bb96a2 packages/sdks/src/functions/get-content/snapshots/generate-content-url.test.ts.snap View secret
314150 Triggered Generic High Entropy Secret 7bb96a2 packages/sdks/src/functions/get-content/snapshots/generate-content-url.test.ts.snap View secret
314150 Triggered Generic High Entropy Secret 7bb96a2 packages/sdks/src/functions/get-content/snapshots/generate-content-url.test.ts.snap View secret
314150 Triggered Generic High Entropy Secret 7bb96a2 packages/sdks/src/functions/get-content/snapshots/generate-content-url.test.ts.snap View secret
314150 Triggered Generic High Entropy Secret 7bb96a2 packages/sdks/src/functions/get-content/snapshots/generate-content-url.test.ts.snap View secret
🛠 Guidelines to remediate hardcoded secrets
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secrets safely. Learn here the best practices.
  3. Revoke and rotate these secrets.
  4. If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.

To avoid such incidents in the future consider


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

/**
* Flatten a nested MongoDB query object into a flat object with dot-separated keys.
* $ keys are not flattened and are left as is.
*/

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you give some examples in the comment to explain the transformation

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure! added, please let me know if we should add anything else

@samijaber samijaber merged commit 70fccea into BuilderIO:main May 1, 2024
22 checks passed
@Conceptiks
Copy link

@samijaber I don't know if this is the right place for it, but after updating to the latest version of the SDK, my query (including $or will no longer work:

$or: [
                {
                    $and: [{ startDate: { $lte: Date.now() } }, { endDate: { $gte: Date.now() } }],
                },
                {
                    $and: [{ startDate: { $exists: false } }, { endDate: { $exists: false } }],
                },
            ],

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

Successfully merging this pull request may close these issues.

$elemMatch operator does not work in the new SDK
4 participants