Skip to content

Error: Can't use $diacriticSensitive with String. #16

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

Open
bruno2kd opened this issue May 14, 2019 · 0 comments
Open

Error: Can't use $diacriticSensitive with String. #16

bruno2kd opened this issue May 14, 2019 · 0 comments

Comments

@bruno2kd
Copy link

bruno2kd commented May 14, 2019

I'm sorry, I am new to this and I am not sure this is the right place to post.

I am trying to do a diacritic insensitive search:

on the client:

const q = {
                query: {
                    name: {
                        $search: "frénch",
                        $diacriticSensitive: false,
                    },
                },
            };

            const res = await api.products.find(q);

Products hooks:

module.exports = {
    before: {
        all: [],
        find: [
            search({ fields: ["name"] }),
        ],
        get: [],

The error I get:

Error: Can't use $diacriticSensitive with String.
  File "/app/node_modules/mongoose/lib/schema/string.js", line 598, in SchemaString.castForQuery
          throw new Error('Can\'t use ' + $conditional + ' with String.');
  File "/app/node_modules/mongoose/lib/schematype.js", line 1216, in SchemaString.SchemaType.castForQueryWrapper
        return this.castForQuery(params.$conditional, params.val);
  File "/app/node_modules/mongoose/lib/cast.js", line 288, in cast
                  val[$cond] = schematype.castForQueryWrapper({
  File "/app/node_modules/mongoose/lib/query.js", line 4340, in model.Query.Query.cast
        return cast(model.schema, obj, {
  File "/app/node_modules/mongoose/lib/query.js", line 2087, in model.Query.<anonymous>
        this.cast(this.model);
  File "/app/node_modules/mongoose/lib/helpers/query/wrapThunk.js", line 16, in model.Query._wrappedThunk [as _count]
        fn.call(this, cb);
  File "/app/node_modules/kareem/index.js", line 369, in process.nextTick
          process.nextTick(() => fn.apply(this, arguments));
  File "internal/process/next_tick.js", line 132, in _combinedTickCallback
  File "internal/process/next_tick.js", line 219, in process._tickDomainCallback

Mongodb: 3.6v
feathers-mongodb-fuzzy-search: 1.1.1v

when I do without the line $diacriticSensitive: false it works right but it is diacritic sensitive.
Also, Mongodb docs says that it defaults to diacritic insensitive and it is defaulting for diacritic sensitive for me.

Any clue on what is going wrong?

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

1 participant