Hey, I'm trying to work with relative dates, so li...
# give-feedback
b
Hey, I'm trying to work with relative dates, so like apply rule for users that signed up before a month ago being dynamic, so in the next day, so when users reach 1 month, have the rule enabled. So I created the following query:
Copy code
{
  "$expr": {
    "$lte": [
      "$createdAt",
      {
        "$subtract": [
          "$$NOW",
          2592000000
        ]
      }
    ]
  }
}
But I saw the operations are done manually in the code, I thought there was a mongo memory server running under the hood to allow do any mongo query. And there isn't support for the
$expr
operator (it does work outside aggregations). Is there any plan to support relative date to do something like this? E.g
$$NOW - number
f
We just adopted the Mongo query syntax since it's easy to read and write. Our SDKs have a custom built rules engine that supports a subset of that query language. I have a feeling that
$expr
might be difficult to implement and cause the size of the SDKs to increase substantially. For relative time operations, the easiest solution right now is to add a dynamic attribute like
daysSinceSignUp
I can see us adding a preprocessing step in the future that let's you reference some dynamic variables like $$NOW. So the query could be complex and dynamic, but the end result being passed into the SDK would still be simple and not need $expr.
b
Got it, thaaanks! The
daysSinceSignUp
sounds like a nice solution