当前位置:网站首页>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 .
边栏推荐
- Web开发小妙招:巧用ThreadLocal规避层层传值
- Hardware development notes (10): basic process of hardware development, making a USB to RS232 module (9): create ch340g/max232 package library sop-16 and associate principle primitive devices
- Summary of different configurations of PHP Xdebug 3 and xdebug2
- 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
- 966 minimum path sum
- 自定义限流注解
- Redis insert data garbled solution
- [asp.net core] set the format of Web API response data -- formatfilter feature
- 字符串的使用方法之startwith()-以XX开头、endsWith()-以XX结尾、trim()-删除两端空格
- PHP online examination system version 4.0 source code computer + mobile terminal
猜你喜欢

【mysql】游标的基本使用

LLVM之父Chris Lattner:为什么我们要重建AI基础设施软件

【微信小程序】运行机制和更新机制

Build your own application based on Google's open source tensorflow object detection API video object recognition system (IV)

Infrared thermometer based on STM32 single chip microcomputer (with face detection)

Common English vocabulary that every programmer must master (recommended Collection)

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

use. Net drives the OLED display of Jetson nano

KDD 2022 | realize unified conversational recommendation through knowledge enhanced prompt learning

Swagger UI教程 API 文档神器
随机推荐
1500萬員工輕松管理,雲原生數據庫GaussDB讓HR辦公更高效
Mtcnn face detection
字符串的使用方法之startwith()-以XX开头、endsWith()-以XX结尾、trim()-删除两端空格
Pycharm remote execution
什么是RDB和AOF
防火墙基础之外网服务器区部署和双机热备
Study notes of grain Mall - phase I: Project Introduction
Application layer of tcp/ip protocol cluster
The biggest pain point of traffic management - the resource utilization rate cannot go up
愛可可AI前沿推介(7.6)
Distributed ID
Reviewer dis's whole research direction is not just reviewing my manuscript. What should I do?
966 minimum path sum
15million employees are easy to manage, and the cloud native database gaussdb makes HR office more efficient
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
Chris LATTNER, the father of llvm: why should we rebuild AI infrastructure software
How to turn a multi digit number into a digital list
基于深度学习的参考帧生成
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
【mysql】游标的基本使用