当前位置:网站首页>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 .
边栏推荐
- Aike AI frontier promotion (7.6)
- Distributed ID
- R语言可视化两个以上的分类(类别)变量之间的关系、使用vcd包中的Mosaic函数创建马赛克图( Mosaic plots)、分别可视化两个、三个、四个分类变量的关系的马赛克图
- PG基础篇--逻辑结构管理(事务)
- js之遍历数组、字符串
- Tips for web development: skillfully use ThreadLocal to avoid layer by layer value transmission
- Variable star --- article module (1)
- 'class file has wrong version 52.0, should be 50.0' - class file has wrong version 52.0, should be 50.0
- 性能测试过程和计划
- This year, Jianzhi Tencent
猜你喜欢
Is this the feeling of being spoiled by bytes?
use. Net drives the OLED display of Jetson nano
Pinduoduo lost the lawsuit, and the case of bargain price difference of 0.9% was sentenced; Wechat internal test, the same mobile phone number can register two account functions; 2022 fields Awards an
The mail command is used in combination with the pipeline command statement
[MySQL] trigger
新型数据库、多维表格平台盘点 Notion、FlowUs、Airtable、SeaTable、维格表 Vika、飞书多维表格、黑帕云、织信 Informat、语雀
15 millions d'employés sont faciles à gérer et la base de données native du cloud gaussdb rend le Bureau des RH plus efficace
3D人脸重建:从基础知识到识别/重建方法!
审稿人dis整个研究方向已经不仅仅是在审我的稿子了怎么办?
Manifest of SAP ui5 framework json
随机推荐
【mysql】触发器
Intel 48 core new Xeon run point exposure: unexpected results against AMD zen3 in 3D cache
Yyds dry goods count re comb this of arrow function
[DSP] [Part 1] start DSP learning
如何实现常见框架
Redis insert data garbled solution
Data Lake (VIII): Iceberg data storage format
PHP online examination system version 4.0 source code computer + mobile terminal
数据湖(八):Iceberg数据存储格式
Database - how to get familiar with hundreds of tables of the project -navicat these unique skills, have you got it? (exclusive experience)
全网最全的新型数据库、多维表格平台盘点 Notion、FlowUs、Airtable、SeaTable、维格表 Vika、飞书多维表格、黑帕云、织信 Informat、语雀
Build your own application based on Google's open source tensorflow object detection API video object recognition system (IV)
PHP saves session data to MySQL database
Solution to the 38th weekly match of acwing
document.write()的用法-写入文本——修改样式、位置控制
动态切换数据源
Application layer of tcp/ip protocol cluster
Pat 1078 hashing (25 points) ⼆ times ⽅ exploration method
use. Net analysis Net talent challenge participation
Pat 1085 perfect sequence (25 points) perfect sequence