In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "how to use the recursive index in RavenDB". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn how to use the recursive index in RavenDB.
Let's look at the following index (Issues/Permissions):
/ / Issues/Permissions index definitionmap ("Issues", issue = > {var groups = issue.Groups.reduce (recurse_groups, {}); return {Groups: Object.keys (groups), Users: issue.Users};}); function recurse_groups (accumulator, grpId) {if (grpId = = null | | accumulator.hasOwnProperty (grpId) return accumulator; accumulator [grpId] = null; var grp = load (grpId, "Groups") If (grp = = null | | grp.Parents = = null) return accumulator; return grp.Parents.reduce (recurse_groups, accumulator);}
This is an JS index that has a map () function on the Issues collection. For each question, we index the users of the problem and the groups that are allowed to access it (recursively).
This query has two clauses; it is either assigned to us directly or through a group. The key here is the load () call in recurse_groups () and inside, in the index. It scans up the defined group and its parents until we have a simple structure in the index that is easy to search.
RavenDB ensures that every time a document referenced by load () in the index is updated, all documents referencing it are re-indexed. In our case, whenever the group is updated, we re-index all related questions to match the new permission structure.
One of the core principles of RavenDB is that you can push more work to the index and keep the query fast and simple. This is a good example of how we can arrange data by pushing work to the background index in a very elegant way.
Thank you for reading, the above is the content of "how to use the recursive index in RavenDB". After the study of this article, I believe you have a deeper understanding of how to use the recursive index in RavenDB, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.