Comments (6)
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.
"LIKE" does not seem to work
from nano-sql.
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:
- 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...
- 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.
I use redis.
from nano-sql.
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.
Marking this resolved, feel free to repon it if you run into this issue again.
from nano-sql.
Related Issues (20)
- NODERAWFS error for some adapters
- Cannot insert a record with an id of 0 (zero) if the id field is a primary key
- Index does not be built correctly.
- [HELP] Increment value HOT 1
- TTL feature always status time -1
- Incorrect behavior with joins and filters
- jsLoad not respect unique index
- Why can column names not begin with an underscore? HOT 1
- Bug with select from HOT 2
- foreignKey: onUpdate support HOT 1
- copy database
- nSQL: Can't do a query before the database is connected! HOT 1
- Can't query tables after restart, log parsing error HOT 1
- [Meta] Is this project still maintained? HOT 3
- LOG file "backs up" every change to a row HOT 1
- Selection of date types with undefined values
- Adding support for WebExtensions
- Support for Capacitor?
- Remove WebSQL usage and/or method calls from this repository
- Does nanoSQL work correctly on Safari s it does on Chrome?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nano-sql.