Hello. I have some problems dealing with database.
I want to store retrieved value from one database to another database.
Here’s my work below.
I am making certain curation site.
I want to show multiple images of the product what I clicked.
When I click ‘Show Product’ button, It retrieves product name and query the data for images from database storing src data of images.
Since database is quite heavy, (In some product, even computer was shut down!) I divided DB along with product categories. but after that, there may be some problem occurred.
when I use only one DB, there was no problem. But now I divided my DB into many parts, so I should use new DB which stores image data temporarily from original DB. (That’s because gallery can be linked to only one dataset as you know)
Retrieving product name and image from original DB works fine, but I don’t know how to move this retrieved value to my new temporary DB. I’ve been searched many times, but I don’t have any idea at all.
Here is my code below.
export function PdButton_click(event) {
let $item = $w.at(event.context);
let PdNumber = $item('#productdata').getCurrentItem().productNum
session.clear
session.setItem("Name", PdNumber)
wixLocation.to('/detail')
}
import wixData from 'wix-data';
import {session} from 'wix-storage';
$w.onReady(function () {
const value1 = session.getItem("Name")
console.log(value1)
wixData.query("img_TB_Bottom")
.eq("imgNumber", value1)
.find()
.then( (res) => {
console.log(res.items[0].img)
})
})
I want to store my retrieved value from one DB to my new temporal DB. Please give me some advice.
Thank you so much in advance! and have a good day 
If this is your retrieved VALUE…
import wixData from'wix-data';
import{session}from'wix-storage';
$w.onReady(function(){
const value1 = session.getItem("Name")
console.log(value1)
wixData.query("img_TB_Bottom").eq("imgNumber", value1)
.find()
.then((res)=>{console.log(res.items[0].img)
//then you should continue with your code here.....
})
})
You have a second “Temporal-DB” where you want to store/save your VALUE.
Then you should use this one…
let toSave = {
"title": "Mr.",
"first_name": "John",
"last_name": "Doe"
};
wixData.save("Temporal-DB", toSave)
.then( (results) => {
let item = results; //see item below
})
.catch( (err) => {
let errorMsg = err;
});
Put things together and you will get your result.
You can also use INSERT instead of SAVE.
Thank you for your help 
I could store product name to new database.
but I am having difficulty in storing my images to new DB
wixData.query( “img_TB_Bottom” )
.eq( “imgNumber” , value1)
.find()
.then( (res) => {
session.setItem( “Image” , res.items[ 0 ].img)
console.log(res.items[ 0 ].img)
})
const value2 = session.getItem( “Image” )
console.log(value2)
let toSave = {
“imgNumber” : value1,
“img” : value2
}
console.log(toSave)
wixData.save( "gallery" , toSave)
.then( (results) => {
let item = results; //see item below
console.log(item)
Here is the code for storing values to new DB.
but in case of image, there is a problem.
image data isn’t stored in new DB. Instead, [object object] is stored. Could you please give me some advice on this issue? Thank you so much in advance!
@searchbjd
You should work more with CONSOLE-LOGs.
This little helper, will help you to solve your coding-issues.
for example… (ohhhh wait ! ! ! You already do it! )
console.log(res.items[0].img)
What do you get as RESULT in CONSOLE ?
Inspect this result and try to understand it’s structure, then you will be able to find a solution for your question.
@russian-dima
This is the result of ‘res.items[0].img’
I want to move this images as it is to new DB. but in my code, it is stored in form of [object Object].
I am thinking of several possibilities, but I don’t have clear solution for it…!
I think most urgent problem is to move image data in form of array. in my DB, image data is stored as below.
[
{
“slug”: “7b9da6_f42a880ee5274dba8bd60c070af65537~mv2”,
“src”: “wix:image://v1/7b9da6_f42a880ee5274dba8bd60c070af65537~mv2.jpg/TB_Bottom_15_05_01jpg#originWidth=570&originHeight=560”,
“title”: “”,
“type”: “image”,
“settings”: {}
},
{
“slug”: “7b9da6_af5082ea60c946ac9c6c65136058b6da~mv2”,
“src”: “wix:image://v1/7b9da6_af5082ea60c946ac9c6c65136058b6da~mv2.jpg/TB_Bottom_15_05_02jpg#originWidth=570&originHeight=560”,
“title”: “”,
“type”: “image”,
“settings”: {}
}
]
What i want to do is to move this combination of string to new DB as it is… 
@searchbjd
Try this one, does it work for you ?
console.log(res.items[0].img[0].src)
console.log(res.items[0].img[0].slug)
@russian-dima yes, It works properly
It looks like I should concatenate all the information stored at array of image in a row. I just want to move ‘media gallery’ formed data in existed DB to new DB with exact same form. I don’t understand, and don’t know how to do it…
https://www.wix.com/velo/reference/wix-dataset/dataset/save (dataset)
https://www.wix.com/velo/reference/wix-data/save (query)
I like to work the flexible way, so i don’t take a dataset… (try this way…)
import wixData from 'wix-data';
let toSave = {
"title": res.items[0].title,
"image": res.items[0].img[0].src,
"slug": res.items[0].img[0].slug
};
wixData.save("YourNewCollection", toSave)
.then( (results) => {
let item = results;
console.log(results)
} )
.catch( (err) => {
let errorMsg = err;
} );
Ok, it’s time to go to bed. Good luck! 
@russian-dima Thank you for your help! Have a good night 