Skip to content
Snippets Groups Projects
Commit ad0d235a authored by wactbprot's avatar wactbprot
Browse files

customer Adress --> address

parent afe8338c
No related branches found
No related tags found
No related merge requests found
......@@ -5,7 +5,7 @@ cin <- cdbIni()
cin$DBName <- "vaclab_db"
cin$view <- "cal"
cin$design <- "new"
cin$show <- "calibration"
## out
cout <- cdbIni()
cout$DBName <- "vl_db"
......@@ -14,16 +14,20 @@ ids <- cdbGetView(cin)$res$rows
N <- length(ids)
for(i in 1:N){
pf <- cin$fromJSON(getURL(paste0(srv
, cin$DBName
, "/_design/"
,cin$design
,"/_show/calibration/"
,ids[[i]]$id )))
cout$id <-ids[[i]]$key$new_id
# secure is secure
cin$id <- ids[[i]]$id
pf <- cdbGetShow(cin)$res
cout$id <- ids[[i]]$key$new_id
## secure is secure
pf$old_id <- ids[[i]]$id
cout$dataList <- pf
res <- cdbUpdateDoc(cout)
res <- cdbUpdateDoc(cout)$res
print(res)
}
\ No newline at end of file
......@@ -3,13 +3,13 @@ library("R4CouchDB")
## in
cin <- cdbIni()
cin$DBName <- "vaclab_db"
cin$DBName <- "vl_db"
cin$view <- "cus"
cin$design <- "new"
cin$design <- "hlp"
## out
cout <- cdbIni()
cout$DBName <- "vl_db"
cout$DBName <- "tst_db"
ids <- cdbGetView(cin)$res$rows
N <- length(ids)
......@@ -17,8 +17,10 @@ N <- length(ids)
for(i in 1:N){
cin$id <- ids[[i]]$id
pf <- cdbGetDoc(cin)$res
cout$id <-ids[[i]]$key$new_id
# cout$id <-ids[[i]]$key$new_id
pf$Customer$Address <- pf$Customer$Adress
pf$Customer$Adress <- NULL
cout$id <- cin$id
cout$dataList <- pf
res <- cdbUpdateDoc(cout)
}
\ No newline at end of file
......@@ -8,20 +8,28 @@ function (doc, req) {
doc.Calibration.Standard){
var dc = doc.Calibration;
// certificate & issue
var ssign = dc.Sign.split(/[-_]/)
, cert = ssign[0]
, issue = ssign[1]
// new
// new id
ndoc["_id"] = ["cal"
, dc.Year
, dc.Standard
, dc.Type.toLowerCase()
, dc.Sign].join("-")
, cert
, issue].join("-")
ndoc.Calibration = {};
ndoc.Calibration.Year = dc.Year
ndoc.Calibration.Type = dc.Type
ndoc.Calibration.Sign = dc.Sign
ndoc.Calibration.Standard = dc.Standard
ndoc.Calibration.Year = dc.Year
ndoc.Calibration.Type = dc.Type
//
ndoc.Calibration.Certificate = cert
ndoc.Calibration.Issue = issue
ndoc.Calibration.Standard = dc.Standard
if(dc.Measurement){
var dcm = dc.Measurement;
......@@ -69,7 +77,17 @@ function (doc, req) {
}
// new
if(dcm.CalibrationObject){
ndoc.Calibration.CalibrationObject = dcm.CalibrationObject;
var N = dcm.CalibrationObject.length;
if(N == 1){
ndoc.Calibration.CustomerObject = dcm.CalibrationObject[0];
}
if(N >1){
ndoc.Calibration.CustomerObject = dcm.CalibrationObject[0];
ndoc.Calibration.CalibrationObject = [];
for(var j = 1; j < N; j++){
ndoc.Calibration.CalibrationObject.push(dcm.CalibrationObject[j])
}
}
}
// new
if(dcm.Standard){
......@@ -93,7 +111,7 @@ function (doc, req) {
}
return {
"headers" : {"Content-Type" : "application/json"},
"headers" : {"Content-Type" : "application/json; charset=utf-8"},
"body" : JSON.stringify(ndoc)
}
};
......@@ -38,7 +38,7 @@ function (doc, req) {
}
return {
"headers" : {"Content-Type" : "application/json"},
"headers" : {"Content-Type" : "application/json; charset=utf-8"},
"body" : JSON.stringify(ndoc)
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment