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

duplicate doc show

parent 22ddcf41
No related branches found
No related tags found
No related merge requests found
function (doc, req) {
var dupDoc = {},
dc = doc.Calibration,
ds = doc.Sign;
// example url:
// http://localhost:5984/vaclab_db/_design/e-share/_show/dup/73eda2bf9694bb4f78edaecba90cdc49
var
dc = doc.Calibration,
ds = dc.Sign,
ss = ds.split(/[-_]+/),
nd = new Date(),
s0 = ss[0], // main sign
s1 = ss[1], // sub sign
ns1 = ""; // new sub sign
if(doc &&
dc &&
typeof dc == "object" &&
ds){
var tn1 = "" + (parseInt("1" + s1, 10) + 1);
tn1 = tn1.substr(1,tn1.length-1);
var dupd = {
Calibration:{
Sign: s0 + "_" + tn1,
Type: req.query.type || dc.Type,
Year: "" + nd.getFullYear(),
Standard: req.query.standard || dc.Standard,
Presettings:{
}
}
};
}else{
dupDoc.error = "Doc seems to be no calibration";
var dupd = {error: "Doc seems to be no calibration"};
}
return dupDoc;
return toJSON(dupd);
};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment