我正在从 PowerShell脚本将文档上传到 RavenDB 。这里是:
$Timestamp = (Get-Date).ToBinary()
$Url = "http://127.0.0.1:8080/databases/DiskStat/docs"
$diskObject = New-Object PSObject @{
"@metadata" = New-Object psobject @{
"Raven-Entity-Name" = "Entries"
}
Timestamp = $Timestamp
Computer = $comp
Disk = $disk.DeviceID
Size = $disk.Size
Free = $disk.FreeSpace
}
[string]$diskJson = (ConvertTo-Json $diskObject)
Invoke-RestMethod -Uri $Url -Method Put -Body $diskJson | Out-Null
问题是新文档不属于任何集合,@metadata
被忽略。文档在数据库中看起来像这样:
{
"Size": 52427931648,
"Timestamp": -8588258377456088029,
"Computer": "710H0001",
"Free": 27922563072,
"Disk": "C:",
"@metadata": {
"@id": "423b5bdf-fe59-4530-8047-bc48d98ee363",
"Last-Modified": "2013-08-06T06:05:42.6982277Z",
"@etag": "00000001-0000-a900-0000-000000000001",
"Non-Authoritative-Information": false
}
}
所以我不得不时不时地给它打补丁来分配Raven-Entity-Name
。酷 RavenDB 伙计们,请帮帮我