当前位置:网站首页>Ravendb starts -- document metadata
Ravendb starts -- document metadata
2022-07-06 21:06:00 【Uncle meow】
We can store any data content in the document , For example, in the order document, we will store the order status 、 Order item quantity 、 Order amount and so on . But we also need to store some content unrelated to the order document , For example, who modified the order document 、 When did you modify the order document , It's time to Document Metadata ( Document metadata , Let's translate it like this for the time being ) Debut .
Metadata What is stored by default
Metadata The storage format of is the same as the document itself Json,RavenDB Use Metadata Store several important information about tracking documents :
- Collection name , Stored in @collection in , How can this attribute determine which set the data document is stored in , If this value is not set , Data documents will be stored in @empty Collection ;
- Last modification date of the document , Stored in @last-modified Properties of the , When storing format UTC;
- Client type , This is a Key , We can go through this Key Know the type of client , Common types are shown in the following table :
type | explain |
---|---|
Raven-Clr-Type | .NET client |
Raven-Java-Class | Java client |
Raven-Python-Class | Python client |
Customize Metadata Property naming conventions
Besides using RavenDB Built in Metadata In addition to attributes, we can also customize Metadata attribute , For example, we need to record who last modified the order document , Then we can customize Metadata attribute Last-Modified-By-User, The code is as follows :
using Raven.Client.Documents; var store = new DocumentStore { Urls = new[] { "http://localhost:8080" }, Database = "Tasks" }; store.Initialize(); using (var session = store.OpenSession()) { var order = session.Load<Order>("orders/1-A"); // The server will not be requested again , Because when we query data documents , //Metadata It will also be returned to the client together var metadata = session.Advanced.GetMetadataFor(order); metadata["Last-Modified-By-User"] = " Zhang San "; session.SaveChanges(); }
We are RavenDB Studio View in orders/1-A The data content , We can see the custom one Metdata Attribute already exists with Metadata The node is down , Here's the picture .
Generally speaking, we seldom use this form to operate in actual development Metadata , We will use events to operate , This will be explained in detail in the later column , Here you only need to know what we are talking about now .
TIP: When we're in RavenDB See in the document with @ At the beginning Metadata Attribute , It means that this attribute is RavenDB Reserved for your own use , So we are expanding Metadata You can't use the same attribute name when using attributes , We customize Metadata Attributes need to follow Pascal nomenclature (PascalCase) perhaps Pascal-Case Nomenclature ( The words that make up the attribute name are capitalized , Use... Between words - Division of no. ), Of course, you can also not follow this suggestion .
边栏推荐
- 快过年了,心也懒了
- PHP saves session data to MySQL database
- Tips for web development: skillfully use ThreadLocal to avoid layer by layer value transmission
- Spark SQL chasing Wife Series (initial understanding)
- @PathVariable
- Detailed explanation of knowledge map construction process steps
- 2110 summary of knowledge points and common problems in redis class
- Why do job hopping take more than promotion?
- The mail command is used in combination with the pipeline command statement
- use. Net drives the OLED display of Jetson nano
猜你喜欢
Common English vocabulary that every programmer must master (recommended Collection)
Laravel笔记-自定义登录中新增登录5次失败锁账户功能(提高系统安全性)
The biggest pain point of traffic management - the resource utilization rate cannot go up
LLVM之父Chris Lattner:为什么我们要重建AI基础设施软件
Interviewer: what is the internal implementation of ordered collection in redis?
Opencv learning example code 3.2.3 image binarization
【OpenCV 例程200篇】220.对图像进行马赛克处理
Study notes of grain Mall - phase I: Project Introduction
数据湖(八):Iceberg数据存储格式
Laravel notes - add the function of locking accounts after 5 login failures in user-defined login (improve system security)
随机推荐
@PathVariable
如何实现常见框架
正则表达式收集
ICML 2022 | flowformer: task generic linear complexity transformer
OSPF multi zone configuration
User defined current limiting annotation
SAP UI5 框架的 manifest.json
No Yum source to install SPuG monitoring
Comprehensive evaluation and recommendation of the most comprehensive knowledge base management tools in the whole network: flowus, baklib, jiandaoyun, ones wiki, pingcode, seed, mebox, Yifang cloud,
15million employees are easy to manage, and the cloud native database gaussdb makes HR office more efficient
After working for 5 years, this experience is left when you reach P7. You have helped your friends get 10 offers
HMS core machine learning service creates a new "sound" state of simultaneous interpreting translation, and AI makes international exchanges smoother
Detailed explanation of knowledge map construction process steps
Laravel notes - add the function of locking accounts after 5 login failures in user-defined login (improve system security)
OSPF多区域配置
R language visualizes the relationship between more than two classification (category) variables, uses mosaic function in VCD package to create mosaic plots, and visualizes the relationship between tw
[MySQL] basic use of cursor
Kubernetes learning summary (20) -- what is the relationship between kubernetes and microservices and containers?
Chris LATTNER, the father of llvm: why should we rebuild AI infrastructure software
强化学习-学习笔记5 | AlphaGo