Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regex Problem #11

Open
gustavoleitao opened this issue Aug 24, 2020 · 1 comment
Open

Regex Problem #11

gustavoleitao opened this issue Aug 24, 2020 · 1 comment
Assignees
Labels

Comments

@gustavoleitao
Copy link

gustavoleitao commented Aug 24, 2020

The regex filter doesn't work properly. The example in README may not be updated.

My code:

const express = require('express')
const bodyParser= require('body-parser')
const app = express()
const mongoose = require('mongoose')
const actions = require('mongoose-rest-actions')
const mquery = require('express-mquery')

// Configurations
mongoose.plugin(actions)
app.use(express.json())
app.use(bodyParser.urlencoded({ extended: true }))
app.use(mquery({ limit: 1000, maxLimit: 10000 }));

mongoose.connect('mongodb://localhost:27017/user-db', { useNewUrlParser: true, useUnifiedTopology: true})

//model

const Schema = mongoose.Schema
const Model = mongoose.model

const userSchema = new Schema({
  name: {
    type: String,
    required: true
  }
})
const User = new Model('User', userSchema)

//routes

app.get('/user', async (req, res) =>{

  const options = req.mquery

  User.get(options, (error, result) => {
    if (error){
      res.status(500).send(error)
    }else{
      res.status(202).send(result)
    }
  })

})

app.listen(3000)

The test:

GET /user?query={"name":{"$regex":"/Bo$/"}}
@lykmapipo lykmapipo added the bug label Aug 25, 2020
@lykmapipo lykmapipo self-assigned this Aug 25, 2020
@elreco
Copy link

elreco commented Sep 6, 2020

Hello, can we make a request with LIKE and Case Insensitive ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants