loopbackio / loopback-connector-couchdb2

LoopBack Connector for Couchdb
Other
12 stars 11 forks source link

Regex issues with "like and nlike" #51

Closed Danwakeem closed 6 years ago

Danwakeem commented 6 years ago

Description/Steps to reproduce

If you try and run a like or nlike query using javascript regular expression syntax you get a blank $regex operator.

name: 'Error',
  error: 'invalid_operator',
  reason: 'Invalid operator: $regex',
  scope: 'couch',
  statusCode: 400,
.....
body: '{"selector":{"loopback__model__name":"Post","$and":[{"loopback__model__name":"Post","keyword":{"$regex":{}}}]},....

Link to reproduction sandbox

Loopback-Sandbox repo

Expected result

{
  "data": [
    {
      "keyword": "abc",
      "id": "sample_doc",
      "_rev": "1-efe66b28ebdb02928354bd357074d562"
    }
  ]
}

Actual Result

{
  "error": {
    "statusCode": 400,
    "name": "Error",
    "message": "Invalid operator: $regex"
  }
}

Additional information

This error was opened as an issue here strongloop/loopback-connector-cloudant#189 but appears to originate from this project.

It seems that both CouchDB and Cloudant require PCRE style regular expressions but the loopback documentation implies that you can use the javascript RegExp.

jannyHou commented 6 years ago

fixed in https://github.com/strongloop/loopback-connector-couchdb2/pull/52, thanks!

Feel free to reopen it if you have other questions.