当前位置:网站首页>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 .
边栏推荐
- 【论文解读】用于白内障分级/分类的机器学习技术
- 什么是RDB和AOF
- Reinforcement learning - learning notes 5 | alphago
- 硬件开发笔记(十): 硬件开发基本流程,制作一个USB转RS232的模块(九):创建CH340G/MAX232封装库sop-16并关联原理图元器件
- JS操作dom元素(一)——获取DOM节点的六种方式
- Math symbols in lists
- js之遍历数组、字符串
- SAP Fiori应用索引大全工具和 SAP Fiori Tools 的使用介绍
- Web开发小妙招:巧用ThreadLocal规避层层传值
- What is the difference between procedural SQL and C language in defining variables
猜你喜欢

Aiko ai Frontier promotion (7.6)

【OpenCV 例程200篇】220.对图像进行马赛克处理

No Yum source to install SPuG monitoring

for循环中break与continue的区别——break-完全结束循环 & continue-终止本次循环

Laravel笔记-自定义登录中新增登录5次失败锁账户功能(提高系统安全性)

OneNote 深度评测:使用资源、插件、模版

15million employees are easy to manage, and the cloud native database gaussdb makes HR office more efficient

Why do job hopping take more than promotion?

Application layer of tcp/ip protocol cluster

基于深度学习的参考帧生成
随机推荐
js 根据汉字首字母排序(省份排序) 或 根据英文首字母排序——za排序 & az排序
js中,字符串和数组互转(一)——字符串转为数组的方法
After working for 5 years, this experience is left when you reach P7. You have helped your friends get 10 offers
What key progress has been made in deep learning in 2021?
PHP saves session data to MySQL database
硬件开发笔记(十): 硬件开发基本流程,制作一个USB转RS232的模块(九):创建CH340G/MAX232封装库sop-16并关联原理图元器件
Reflection operation exercise
3D face reconstruction: from basic knowledge to recognition / reconstruction methods!
Laravel笔记-自定义登录中新增登录5次失败锁账户功能(提高系统安全性)
2022菲尔兹奖揭晓!首位韩裔许埈珥上榜,四位80后得奖,乌克兰女数学家成史上唯二获奖女性
R语言可视化两个以上的分类(类别)变量之间的关系、使用vcd包中的Mosaic函数创建马赛克图( Mosaic plots)、分别可视化两个、三个、四个分类变量的关系的马赛克图
1500万员工轻松管理,云原生数据库GaussDB让HR办公更高效
[DSP] [Part 1] start DSP learning
OneNote 深度评测:使用资源、插件、模版
【微信小程序】運行機制和更新機制
el-table表格——sortable排序 & 出现小数、%时排序错乱
2110 summary of knowledge points and common problems in redis class
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
use. Net analysis Net talent challenge participation
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,