Custom schema remember previous value
dbartumeu opened this issue · 11 comments
Hi:
I'm using a custom schema like this
new querymen.Schema({
store: {
type: RegExp,
paths: ['store'],
normalize: true,
},
});
If I made a request like this:
myurl.com/stores/?store=amazon, everithing is ok, but if I made a request after, but without any params: myurl.com/stores/, for some reason i keep getting this { store: /amazon/i } in my query
Is there a way to fix this behavior? or maybe I'm missing somethings.
best regards.
I had the same problem. I did everything but nothing yet...
Tnks
Sorry about the delay. Could you please post the full code of what you're doing (including express middleware)?
In my case this is my express config:
module.exports = function (config, arrayDB) {
const app = express()
app.set('port', config.port)
app.use(helmet())
app.use(cors())
app.use(bodyParser.urlencoded({
extended: true
}))
app.use(bodyParser.json())
app.use(methodOverride())
app.set('secretKey', config.secretKey)
app.use(express.static('public'))
app.use((req, res, next) => {
debug(req.method + ' - ' + req.url)
next()
})
app.set('sqlConnectorOperacional', arrayDB[0])
app.set('sqlConnectorFinanceiro', arrayDB[1])
load('models')
.then('controllers')
.then('routes')
.into(app)
return app
}
and this is a route where I use querymen:
const querymen = require('querymen')
module.exports = function (app) {
const controller = app.controllers.relatorio
let logSchema = {
limit: 100,
sort: '-created_on',
codigo: Number,
find: {
type: RegExp,
paths: [
'operacao',
'usuario.nome',
'usuario.email',
'relatorio.cartao.cpf',
'relatorio.cartao.matricula'
],
bindTo: 'query'
},
after: {
type: Date,
paths: [ 'created_on' ],
operator: '$gte'
},
before: {
type: Date,
paths: [ 'created_on' ],
operator: '$lte'
}
}
// Log
app.route('/api/relatorio/log')
.get(querymen.middleware(logSchema), controller.list)
}
@isaacvitor I can't reproduce it. What exactly is happening? Is this happening with all schema parameters?
It would be nice to have a minimum repo with a reproduction.
@diegohaz you're right, really you would cannot reproduce it. Unfortunately I can't put it in a repo.
I don't understand why occurs some kind of cache. I realized that this occurs intermittently.
I also faced with the same issue. I will try to prepare a small repo with example
Have the same issue here.
const userSchema = new Schema({ limit: { max: 1000, default: 20 }, category: { type: String, bindTo: 'select' } })
I have the same problem, has anyone solved the problem?
I will try to review the source code to see if I can fix it.
I solved this problem in #47
Hi guys, I have solved this issue with this pull request, and all the test is passing ;)