Hi all,
I am trying to duplicate an embedded document inside of an embeddedset
property, using some or all the properties of the existing document. This
is an example of a document:
{
"name": "Test name",
"active": true,
"files": [
{
"filename": "text.pdf",
"description": "PDF file",
"hash": "febf62b722d761a3be7294bd11b62331",
"app": #34:0,
"countries": [#21:15, #21:50, #21:170]
}
]
}
The "files" property is an embeddedset of a File class. I want to
duplicate the existing "file" inside the document, and if possible changing
some of the values of the new file, and adding new ones, something like
this:
{
"name": "Test name",
"active": true,
"files": [
{
"filename": "text.pdf",
"description": "PDF file",
"hash": "febf62b722d761a3be7294bd11b62331",
"app": #34:0,
"countries": [#21:15, #21:50, #21:170]
},
{
"filename": "text.pdf",
"description": "PDF file duplicated",
"hash": "febf62b722d761a3be7294bd11b62331",
"app": #34:1,
"countries": [#21:15, #21:50, #21:170],
"cdn": "books.amazon.com"
}
]
}
I know tha I can insert a new file like this:
update 33:0 add files = [{ "@type" : "d", "@class":"File",
"filename":"text.pdf", "description": "PDF file duplicated", "hash":
"febf62b722d761a3be7294bd11b62331", "app": #34:1, "countries": [#21:15,
#21:50, #21:170], "cdn": "books.amazon.com" }]
And I can do a massive update with something like:
update books add files = [{ "@type" : "d", "@class":"File",
"filename":"text.pdf", "description": "PDF file duplicated", "hash":
"febf62b722d761a3be7294bd11b62331", "app": #34:1, "countries": [#21:15,
#21:50, #21:170], "cdn": "books.amazon.com" }]
BUT, if I do it this way, all the documents will have the same values and I
have more than a thousand documents, is there any way to do this in a
massive way?, these are the requirements:
- At least it must duplicate the original file.
- If possible, I want to change the value of some of the properties.
- If possible, I want to add a couple of new properties.
- It needs to be only one script, I cannot write a script for each of
the 1000+ documents.
I was searching for something like "INSERT INTO … SELECT" but for an UPDATE
and using the same document as source (not copying records, just copying
properties). Is that possible or will I have to go with my current SQL
command?
I am using OrientDB 1.7
Regards,
---
--
---
You received this message because you are subscribed to the Google Groups
"OrientDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.