maritz / nohm

node.js object relations mapper (orm) for redis
http://maritz.github.io/nohm/
MIT License
500 stars 64 forks source link

Add option to mark behavior property as "use scored sorting" #134

Open maritz opened 6 years ago

maritz commented 6 years ago

Currently when you define a property with type behavior, it will never use scored indexing for sorts.

This means that for example creating a createdAt behavior automatically means that sorting by it uses redis.sort with O(N+M*log(M)) instead of redis.zrange/zrevrange with O(log(N)+M).

This can be a significant performance issue.

maritz commented 6 years ago

Maybe something like "typeAsNumeric" that adds a step after typecasting as well to additionally type the return of the behaviour to int/float.

This is especially useful for fields like createdAt which is usually defined as readOnly by making the behaviour always return the old value.