Code Monkey home page Code Monkey logo

Comments (3)

SevInf avatar SevInf commented on September 22, 2024

Hi @kodwi.
Could you please share your prisma schema? Thank you.

from prisma.

kodwi avatar kodwi commented on September 22, 2024

@SevInf sure

generator client {
  provider        = "prisma-client-js"
  previewFeatures = ["fullTextSearch"]
}

datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

model Country {
  id     Int    @id @default(autoincrement())
  name   String @unique
  cities City[]
}

model City {
  id        Int        @id @default(autoincrement())
  name      String
  region    String
  countryId Int
  country   Country    @relation(fields: [countryId], references: [id])
  locations Location[]
}

model Location {
  id        String  @id @default(uuid())
  cityId    Int
  city      City    @relation(fields: [cityId], references: [id])
  address   String?
  latitude  Float?
  longitude Float?
}

from prisma.

coooola avatar coooola commented on September 22, 2024

@kodwi
I faced exactly the same problem than you. If you look for a field with a space and that there is a result for it, I have the same error.
I've came up with this workaround for now: I'm just replacing spaces by comas in the searched terms. You still have the correct results in the right order.

In your example it would do:

this._prismaService.country.findMany({
      where: {
        name: {
          contains: searchText,
          mode: 'insensitive',
        },
      },
      orderBy: {
        _relevance: {
          fields: ['name'],
          search: searchText.split(' ').join(','),
          sort: 'desc',
        },
      },
      take: COMMON.COUNTRY_COUNT,
    });

from prisma.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.