-
Notifications
You must be signed in to change notification settings - Fork 1.1k
DATAMONGO-2112 - Allow usage of SpEL expression for index annotation attributes. #647
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
Conversation
db07b71
to
a7cef4e
Compare
We added expireAfter which accepts numeric values followed by the unit of measure (d(ays), h(ours), m(inutes), s(econds)) or a Spring template expression to the Indexed annotation. @indexed(expireAfter = "10s") String expireAfterTenSeconds; @indexed(expireAfter = "1d") String expireAfterOneDay; @indexed(expireAfter = "#{@mySpringBean.timeout}") String expireAfterTimeoutObtainedFromSpringBean;
… & geoIndex names as well as compound index definition. We now also evaluate SpEL expressions for the name of indices as well as the def attribute of the compound index definition. @CompoundIndex(name = "#{'cmp' + 2 + 'name‘}“, def = "#{T(org.bson.Document).parse(\"{ 'foo': 1, 'bar': -1 }\")}") class WithCompoundIndexFromExpression { // … } An expression used for Indexed.expireAfter may now not only return a plain String value with the timeout but also a java.time.Duration.
da5a87d
to
1a571a1
Compare
return Duration.ofHours(timeout); | ||
case "m": | ||
return Duration.ofMinutes(timeout); | ||
case "s": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi,
Looks like ms
missed here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for having a look. This is intentional uses seconds granularity. We will still get milliseconds through DurationStyle
in alignment with Spring Boot's duration style parsing.
Align Indexed(expireAfter) default to empty string according to the documentation. Slightly reword Javadoc. Import DurationStyle to reuse duration parsing until Spring Framework provides a similar utility. Document ISO-8601 duration style. Prevent null index name evaluation to render "null" as String. Convert assertions from Hamcrest to AssertJ.
960b24d
to
a066ee0
Compare
We added expireAfter which accepts numeric values followed by the unit of measure (d(ays), h(ours), m(inutes), s(econds)) or a Spring template expression to the Indexed annotation. @indexed(expireAfter = "10s") String expireAfterTenSeconds; @indexed(expireAfter = "1d") String expireAfterOneDay; @indexed(expireAfter = "#{@mySpringBean.timeout}") String expireAfterTimeoutObtainedFromSpringBean; Original pull request: #647.
… & geoIndex names as well as compound index definition. We now also evaluate SpEL expressions for the name of indices as well as the def attribute of the compound index definition. @CompoundIndex(name = "#{'cmp' + 2 + 'name‘}“, def = "#{T(org.bson.Document).parse(\"{ 'foo': 1, 'bar': -1 }\")}") class WithCompoundIndexFromExpression { // … } An expression used for Indexed.expireAfter may now not only return a plain String value with the timeout but also a java.time.Duration. Original pull request: #647.
Align Indexed(expireAfter) default to empty string according to the documentation. Slightly reword Javadoc. Import DurationStyle to reuse duration parsing until Spring Framework provides a similar utility. Document ISO-8601 duration style. Prevent null index name evaluation to render "null" as String. Convert assertions from Hamcrest to AssertJ. Original pull request: #647.
That's merged and polished now. |
We added
@Indexed.expireAfter()
which accepts numeric values followed by the unit of measured
(ays),h
(ours),m
(inutes),s
(econds) or a template expression.The expression used for
@Indexed.expireAfter()
may not only return a plainString
value with the timeout but also ajava.time.Duration
.Additionally expressions can now be used for the
name
attribute of@Indexed
,@GeospatialIndexed
and@CompoundIndex
as well as thedef
attribute of@CompoundIndex
.