Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

findKeys functionality

spcsser edited this page · 1 revision
Clone this wiki locally

ueberDB.findKeys(key, notkey, callback) provides functionality to retrieve a list of key values. The param key defines which data we want to find, excluding data that matches the param notKey (can be null).

How it works

Consider the following entries as example:

test:id1
test:id1:chat:id2
chat:id3:test:id4

We want to find all unique entries for the key part test like in test:test1 but not the other two entries. We would issue the following search: ueberDB.findKeys("test:*","*:*:*");. The first params says we're looking for entries that match test: with anything that follows, but not entries that have multiple colons to exclude entries like test:id1:chat:id2.

Internal details

Depending on the database type, there are currently two strategies too perform queries. For document based dbms like mongodb, dirty or couch we use a regex and tranform the params into regex. The parameters test:* and *:*:* will be transformed into a regular expression: /(?=^test:.*$)(?!^.*:.*:.*$)/.

For relational dbms like mysql or postgres we use the like operator. The parameters test:* and *:*:* translate to this where condition: store.key LIKE 'test:%' AND store.key NOT LIKE '%:%:%'.

Something went wrong with that request. Please try again.