当前位置:网站首页>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 .
边栏推荐
- KDD 2022 | realize unified conversational recommendation through knowledge enhanced prompt learning
- Reference frame generation based on deep learning
- What is the problem with the SQL group by statement
- ICML 2022 | flowformer: task generic linear complexity transformer
- Reviewer dis's whole research direction is not just reviewing my manuscript. What should I do?
- 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,
- After working for 5 years, this experience is left when you reach P7. You have helped your friends get 10 offers
- Pat 1078 hashing (25 points) ⼆ times ⽅ exploration method
- Distributed ID
- Infrared thermometer based on STM32 single chip microcomputer (with face detection)
猜你喜欢
2017 8th Blue Bridge Cup group a provincial tournament
硬件开发笔记(十): 硬件开发基本流程,制作一个USB转RS232的模块(九):创建CH340G/MAX232封装库sop-16并关联原理图元器件
愛可可AI前沿推介(7.6)
3D人脸重建:从基础知识到识别/重建方法!
[200 opencv routines] 220 Mosaic the image
【深度学习】PyTorch 1.12发布,正式支持苹果M1芯片GPU加速,修复众多Bug
2022 fields Award Announced! The first Korean Xu Long'er was on the list, and four post-80s women won the prize. Ukrainian female mathematicians became the only two women to win the prize in history
No Yum source to install SPuG monitoring
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
随机推荐
Laravel笔记-自定义登录中新增登录5次失败锁账户功能(提高系统安全性)
Web开发小妙招:巧用ThreadLocal规避层层传值
新型数据库、多维表格平台盘点 Notion、FlowUs、Airtable、SeaTable、维格表 Vika、飞书多维表格、黑帕云、织信 Informat、语雀
for循环中break与continue的区别——break-完全结束循环 & continue-终止本次循环
The mail command is used in combination with the pipeline command statement
User defined current limiting annotation
全网最全的知识库管理工具综合评测和推荐:FlowUs、Baklib、简道云、ONES Wiki 、PingCode、Seed、MeBox、亿方云、智米云、搜阅云、天翎
Can novices speculate in stocks for 200 yuan? Is the securities account given by qiniu safe?
【OpenCV 例程200篇】220.对图像进行马赛克处理
'class file has wrong version 52.0, should be 50.0' - class file has wrong version 52.0, should be 50.0
@PathVariable
Tips for web development: skillfully use ThreadLocal to avoid layer by layer value transmission
It's almost the new year, and my heart is lazy
[wechat applet] operation mechanism and update mechanism
C # use Oracle stored procedure to obtain result set instance
2022菲尔兹奖揭晓!首位韩裔许埈珥上榜,四位80后得奖,乌克兰女数学家成史上唯二获奖女性
Is this the feeling of being spoiled by bytes?
[200 opencv routines] 220 Mosaic the image
use. Net analysis Net talent challenge participation
Pycharm remote execution