powershell - Store new document to specific collection in RavenDB via REST -
i'm uploading documents ravendb powershell script. here is:
$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
the problem new documents not belong collection, @metadata
ignored. documents looking in database:
{ "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 } }
so have patch time time assign raven-entity-name
. cool ravendb guys, please, me
while metadata returned in @metadata
section, that's not how send in. that's because don't have control on every metadata value. example, passing in etag wouldn't make sense.
instead, metadata values can control, send them in http headers.
$headers = @{"raven-entity-name"="entries"} invoke-restmethod -headers $headers ...
Comments
Post a Comment