LastIndexOf in RavenDB RQL?

Viewed 33

I'm searching for a way to do some string manipulation in RQL. I have a string "xxx.yyy.zzz" and I would like to display this zzz. I found substr function but I cannot find something like lastindexof?

1 Answers
  1. You can make a query on a collection and select (create a projection) using javascript,
    and then use whatever method you like, i.e. lastIndexOf
var query = from user in session.Query<User>()
            select new
            {               
                Location = RavenQuery.Raw<int>("user.Name.lastIndexOf('x')");
            };
  1. You can create a javascript index and make a query on it
    https://ravendb.net/docs/article-page/5.1/Csharp/indexes/javascript-indexes
    Use any javascript method when defining your index field property inside the Map method
Related