qmgo
qmgo copied to clipboard
collation support ?
Hi
Looks like qmgo does not suport collation ? https://docs.mongodb.com/manual/reference/collation/
I have two usecases that depends on collation:
- when create index
- when find with case insensitve match ( search user by username which is case insensitive)
The original mongo driver does support collation. Looks like that qmgo not. Am I right ?
Thanks
Most operations of Qmgo
have collation by parameter option
, but sadly,Qmgo
doesn't have collation when create Index in current version.
@jiangz222 thanks for your reply.
Then, in qmgo, is there any way or workaround that I can do a search with case insensitive, saying search user by username. I know regexp is an option, is there any other options ?
Most operations of
Qmgo
have collation by parameteroption
, but sadly,Qmgo
doesn't have collation when create Index in current version.
You said most operations of qmgo support collation with an option, does Find()/One() support collation ? From below qmgo code, I didn't understand how. Is there an example ? thanks
func (q *Query) One(result interface{}) error { if len(q.opts) > 0 { if err := middleware.Do(q.opts[0].QueryHook, operator.BeforeQuery); err != nil { return err } } opt := options.FindOne()
if q.sort != nil {
opt.SetSort(q.sort)
}
if q.project != nil {
opt.SetProjection(q.project)
}
if q.skip != nil {
opt.SetSkip(*q.skip)
}
if q.hint != nil {
opt.SetHint(q.hint)
}
err := q.collection.FindOne(q.ctx, q.filter, opt).Decode(result)
if err != nil {
return err
}
if len(q.opts) > 0 {
if err := middleware.Do(q.opts[0].QueryHook, operator.AfterQuery); err != nil {
return err
}
}
return nil
}
Most operations of
Qmgo
have collation by parameteroption
, but sadly,Qmgo
doesn't have collation when create Index in current version.You said most operations of qmgo support collation with an option, does Find()/One() support collation ? From below qmgo code, I didn't understand how. Is there an example ? thanks
func (q *Query) One(result interface{}) error { if len(q.opts) > 0 { if err := middleware.Do(q.opts[0].QueryHook, operator.BeforeQuery); err != nil { return err } } opt := options.FindOne()
if q.sort != nil { opt.SetSort(q.sort) } if q.project != nil { opt.SetProjection(q.project) } if q.skip != nil { opt.SetSkip(*q.skip) } if q.hint != nil { opt.SetHint(q.hint) } err := q.collection.FindOne(q.ctx, q.filter, opt).Decode(result) if err != nil { return err } if len(q.opts) > 0 { if err := middleware.Do(q.opts[0].QueryHook, operator.AfterQuery); err != nil { return err } } return nil
}
Not yet! 😢
@jiangz222 thanks for your reply.
Then, in qmgo, is there any way or workaround that I can do a search with case insensitive, saying search user by username. I know regexp is an option, is there any other options ?
About this, sadly, Qmgo can't do anything more than official driver.
请问这个问题解决了吗?我需要collation对中文字段按照拼音进行排序,有其它的解决方案吗? 谢谢!
请问这个问题解决了吗?我需要collation对中文字段按照拼音进行排序,有其它的解决方案吗? 谢谢!
这个功能我记得有, 是在选项里面设置排序方式.