How to save array of json in mongoose
I have the next issue:
I have the variables like this:
links: [{linkTo: "aaa", text: "bbb"}, {linkTo: "ccc", text: "ddd"}],
style: {
color: "green",
backgroundColor: "#dddddd",
borderStyle: "solid",
borderWidth: 4,
borderColor: "#bbbbb",
borderRadius: 10,
hoverColor: "#aaaaa",
hoverBackgroundColor: "red"
}
and I want to store them in the mongo DB inside one field called LinksTree (using mongoose).
I tried the following but didn't work (goes stright to the default):
LinksTree: {
links: {
type: Array,
default: []
},
style: {
type: Object,
default: {
color: "black",
backgroundColor: "#dadada",
borderStyle: "solid",
borderWidth: 4,
borderColor: "#dadada",
borderRadius: 10,
hoverColor: "#31941F",
hoverBackgroundColor: "white"
}
}
},
How can I solve that issue?
from Recent Questions - Stack Overflow https://ift.tt/3pZUQUx
https://ift.tt/eA8V8J
Comments
Post a Comment