putting document with metadata

24 views
Skip to first unread message

bgmi...@gmail.com

unread,
Dec 9, 2021, 5:38:26 AM12/9/21
to RavenDB - an awesome database
With a javascript patch operation I'm able to put a document, but having difficulty setting the metadata. The old way of doing it in 3.5 is not working. Here's my script:

from CommunityDocuments as c
update
{
    put("CommunityInfo/" + id(c).replace("CommunityDocuments/", ""),
    {
        Name: this.Name,
        Slug: this.Slug,
        IsNetworkAdmin: this.IsNetworkAdmin,
        NetworkCode: this.NetworkCode
    },
    {
        "@collection": "CommunityInfos",    
    "Raven-Clr-Type": "PlayCaddy.Core.Documents.Community, PlayCaddy.Core"
})
}

Grisha Kotler

unread,
Dec 9, 2021, 5:47:51 AM12/9/21
to rav...@googlegroups.com
In v4.x and up, the metadata must be part of the document:

from CommunityDocuments as c
update
{
    put("CommunityInfo/" + id(c).replace("CommunityDocuments/", ""),
    {
        Name: this.Name,
        Slug: this.Slug,
        IsNetworkAdmin: this.IsNetworkAdmin,
        NetworkCode: this.NetworkCode,
        ["@metadata"]: {

            "@collection": "CommunityInfos",    
            "Raven-Clr-Type": "PlayCaddy.Core.Documents.Community, PlayCaddy.Core"
        }
    })
}

Grisha Kotler
Team Leader   /   Hibernating Rhinos LTD
Skype:  grisha.kotler
Support:  sup...@ravendb.net
  


--
You received this message because you are subscribed to the Google Groups "RavenDB - an awesome database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ravendb/aba4272a-90f9-4902-8c00-0d13e3dc3fd0n%40googlegroups.com.

bgmi...@gmail.com

unread,
Dec 15, 2021, 10:04:45 AM12/15/21
to RavenDB - an awesome database
Thanks Grisha
Reply all
Reply to author
Forward
0 new messages