GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Service adapter `operators` property marked as deprecated while still needed to use MongoDB specific operators starting with `$` · Issue #3431 · feathersjs/feathers

Service adapter operators property marked as deprecated while still needed to use MongoDB specific operators starting with $ #3431

New issue
Copy link
New issue
Copy link
Open
Open
Service adapter operators property marked as deprecated while still needed to use MongoDB specific operators starting with $#3431
Copy link

Description

@Psycholisk
Psycholisk
opened on Feb 22, 2024
Issue body actions

Steps to reproduce

  • Use the @feathersjs/mongodb adapter as a datasesource adapter for your project
  • Add the operator to the queryable fields in the TypeBox querySchema as follows
export const tagQuerySchema = Type.Intersect(
    [
        querySyntax(tagQueryProperties, {
            title: {
                $regex: Type.Any()
            }
        }),
        // Add additional query properties here
        Type.Object({}, { additionalProperties: false })
    ],
    { additionalProperties: false }
)
  • Query the collection with the following query
app.service('tags').find({
  query: {
    title: {
      $regex: /(?:)/i
    }
  }
})

Expected behavior

As per the latest docs, specifying the operator in the querySchema is sufficient to allow custom operators call, without the need to add the option operators: ['$regex'] to the service adapter options.

The query should return the documents that have a title that match this regex expression.

Actual behavior

Instead we get this error error: BadRequest: Invalid query parameter $regex.

Only when I add the operators option (which is marked as deprecated) it works fine.

System configuration

  • Apple M2

Module versions (especially the part that's not working):

  • Feathersjs ^5.0.11
  • Mongodb ^6.1.0

NodeJS version:

  • Node 18.16.0

Operating System:

  • MacOS 14.1.2 (23B92)
Reacted by Ryan Kotzen

Activity

  1. seansps commented on Mar 13, 2024

    @seansps
    seansps
    on Mar 13, 2024
    More actions

    I am running into this same issue, is there a workaround?

    Edit:
    I see, I was able to get it to work adding: operators: ['$regex', '$options'],

  2. junit38 commented on Dec 10, 2024

    @junit38
    junit38
    on Dec 10, 2024
    More actions

    I am running into this same issue, is there a workaround?

    Edit: I see, I was able to get it to work adding: operators: ['$regex', '$options'],

    Where do you added those operators ?

  3. seansps commented on Dec 10, 2024

    @seansps
    seansps
    on Dec 10, 2024
    More actions

    I am running into this same issue, is there a workaround?
    Edit: I see, I was able to get it to work adding: operators: ['$regex', '$options'],

    Where do you added those operators ?

    If you're using TS and generating services, you'll have a .class.ts file like I do, and I added it like so:

    export const getOptions = (app: Application): MongoDBAdapterOptions => {
      return {
        paginate: app.get('paginate'),
        operators: ['$regex', '$options'],
        Model: app
          .get('mongodbClient')
          .then((db) => db.collection('journals'))
          .then((collection) => {
            collection.createIndex({ moduleId: 1 })
            return collection
          }),
        multi: ['remove']
      }
    
  4. junit38 commented on Dec 10, 2024

    @junit38
    junit38
    on Dec 10, 2024 via email
    More actions
    Found it thanks !
    …
    On Tue, Dec 10, 2024, 4:22 PM Sean Schnell ***@***.***> wrote: I am running into this same issue, is there a workaround? Edit: I see, I was able to get it to work adding: operators: ['$regex', '$options'], Where do you added those operators ? If you're using TS and generating services, you'll have a .class.ts file like I do, and I added it like so: export const getOptions = (app: Application): MongoDBAdapterOptions => { return { paginate: app.get('paginate'), operators: ['$regex', '$options'], Model: app .get('mongodbClient') .then((db) => db.collection('journals')) .then((collection) => { collection.createIndex({ moduleId: 1 }) return collection }), multi: ['remove'] } — Reply to this email directly, view it on GitHub <#3431 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/ABUSN4GOVV7JHXSPPQAHTWL2E4BMPAVCNFSM6AAAAABTLDQNCOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKMZSGAYTQNJXHE> . You are receiving this because you commented.Message ID: ***@***.***>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.