我试图通过编写单个查询将文档插入多个集合中。
让我们考虑我有两个集合person
和address
。我想在单个查询中将文档插入到这两个集合中。也就是说,应将{strong> fname,lname 之类的文档插入pesron
集合中,而将 city,state,country 之类的文档插入{{1 }}集合。
有什么我可以实现的,如果有可能提供示例的答案,将不胜感激。
答案 0 :(得分:2)
猫鼬不提供此功能,而且node.js是同步的...因此您不能同时做两件事。建议利用Promise.all
library(rhandsontable)
library(shiny)
foo <- function(M = 2,
Q = 3,
C = 4) {
DF <- data.frame(
m = 1, # m_q_c_vector_from_M_Q_C(M, Q, C)$m,
q = 2, # m_q_c_vector_from_M_Q_C(M, Q, C)$q,
c = 3, # m_q_c_vector_from_M_Q_C(M, Q, C)$c,
h = rep(NA_integer_, M * Q * C),
f = rep(NA_integer_, M * Q * C)
)
ui <- shiny::fluidPage(
shiny::tags$head(
shiny::tags$link(rel = "stylesheet", type = "text/css", href = "styles.css")
),
# Color
shiny::sidebarLayout(
shiny::sidebarPanel(
shiny::sliderInput(
"Number_of_MCMC_samples",
"Number of MCMC samples:",
min = 10,
max = 11111,
value = 111
),
shiny::h4(shiny::helpText(" Larger is better."))
,
shiny::sliderInput(
"Number_of_MCMC_chains",
"Number of MCMC chains:",
min = 1,
max = 4,
value = 1
),
shiny::sliderInput(
"Number_of_lesions",
"Number of lesions:",
min = 1,
max = 1111,
value = 259#
),
shiny::sliderInput(
"Number_of_images",
"Number of images:",
min = 1,
max = 1111,
value = 57
),
shiny::sliderInput(
"C",
"Number of C:",
min = 1,
max = 11,
value = 3
),
shiny::sliderInput(
"M",
"Number of M:",
min = 1,
max = 7,
value = 4
),
shiny::sliderInput(
"Q",
"Number of Q:",
min = 1,
max = 7,
value = 5
),
shiny::h1("Data"),
shiny::h4(
shiny::helpText("Right-click on the table to delete/insert rows.")
),
shiny::h4(shiny::helpText("Double-click on a cell to edit")),
rhandsontable::rHandsontableOutput("hot"),
# Table of h and f ###########################################################
shiny::h5(shiny::helpText(" h = hit = True Positive = TP.")),
shiny::h5(shiny::helpText(" f = false alarms = False Positive = FP."))
),
shiny::mainPanel()
)
)
server <- function(input, output) {
values <- shiny::reactiveValues()
## Handsontable
shiny::observe({
if (!is.null(input$hot)) {
DF = rhandsontable::hot_to_r(input$hot)
} else {
if (is.null(values[["DF"]]))
DF <- DF
else
DF <- values[["DF"]]
}
values[["DF"]] <- DF
values[["dataList"]] <- list(
NL = input$Number_of_lesions,
NI = input$Number_of_images,
h = DF$h,
f = DF$f,
m = DF$m,
q = DF$q,
c = DF$c,
C = input$C,
M = input$M,
Q = input$Q
)
})
output$hot <- rhandsontable::renderRHandsontable({
DF <- values[["DF"]]
if (!is.null(DF))
rhandsontable::rhandsontable(DF,
stretchH = "all")
})
}
shiny::runApp(list(ui = ui, server = server))
return(invisible())
} # function
foo()