Giter VIP home page Giter VIP logo

Comments (6)

only-cliches avatar only-cliches commented on May 14, 2024

It looks like you've already got a good solution set up.

I am working on an ElasticSearch style feature but it's still being tested, in the meantime what you have is a good solution.

Best,
Scott

from nano-sql.

boy12371 avatar boy12371 commented on May 14, 2024

"LIKE" does not seem to work

from nano-sql.

only-cliches avatar only-cliches commented on May 14, 2024

Don't know why I didn't notice this before, but you're using AND, that's your problem.

Unless the nickname AND username match the query you'll get nothing back. Try using OR.

I've also just pushed an update (v1.5.1) that can help with this kind of stuff. Two new things that can help out:

  1. LIKE now uses MySQL wildcard syntax. You can read about it here. A quick example:
nSQL("users").query("select").where(["username", "LIKE", "%richard%"]).exec().then...
  1. You can also use Levenshtein distance to find words spelled close to "richard". Like this:
nSQL("users").query("select").where(["levenshtein(richard, username)", ">", 3]).exec().then...

Levenshtein distance calculates the number of changes needed to match a string. For example the levenshtein distance between "you" and "your" is 1 since you only need to add a single letter for one to match the other.

The Levenshtein feature isn't in the documentation yet but it will be soon.

nanoSQL has also supported regular expressions for a while now, so you could do something like this:

nSQL("users").query("select").where(["username", "REGEX", /richard/g]).exec().then...

from nano-sql.

boy12371 avatar boy12371 commented on May 14, 2024

I use redis.

from nano-sql.

only-cliches avatar only-cliches commented on May 14, 2024

That doesn't matter, the features are identical regardless of the database adapter you're using.

Meaning the MySQL style LIKE syntax will work with Redis, IndexedDB, Localstorage or any other adapter that works with nanoSQL.

from nano-sql.

only-cliches avatar only-cliches commented on May 14, 2024

Marking this resolved, feel free to repon it if you run into this issue again.

from nano-sql.

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.