Truncate and duplicate

Coding a user interface for document editing and processing.

We want to truncate and duplicate documents for global queries.

The idea is to create key-value VAL duplicate at the same time as any new document

where VAL is a value parameter for global query .

New key-value duplicate in VAL bucket would look something like this :

{
"id": "docname"
"val": 145547
}

where 145547 is the parameter value stored in the new document,

and docname is the meta _id of this document.

How should we duplicate new document into shortened key-value data ?

Regards

This query duplicates all documents and does not truncate :

INSERT INTO VAL_bucket (key _k, value _v) SELECT META().id _k, _v FROM document_bucket _v;