Created
June 15, 2013 17:54
-
-
Save AlexMocioi/5788948 to your computer and use it in GitHub Desktop.
eu am facut in felul urmator, este experimental pentru moment dar functioneaza:
1 trebuie sa fii conectat prin vpn sau in reteaua de la iqm, mergi la adresa:
http://172.16.0.52:5984/bd2013/internal_utils/index.html
2. deschizi consola navigatorului (F12)
3. totul este rulat din consola cu navigatorul pornit pentr multe dosare (>500) se poate sa …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.couch.urlPrefix = "http://localhost:5984"; | |
$.couch.info({ | |
success: function(data) { | |
console.log(data); | |
} | |
}); | |
$.couch.db("bd2013").info({ | |
success: function(data) { | |
console.log(data); | |
} | |
}); | |
//asta iti aduce toate documentele | |
$.couch.db("bd2013").allDocs({ | |
success: function(data) { | |
console.log(data); | |
}, | |
//IMOPORTANT!!! pune limita ca altfel trebuie sa dai cu ciocanul in pc | |
limit: 1 | |
}); | |
//asta e un view cu map | |
//este executat ca _temp deci dureaza | |
var mapFunction = function(doc) { | |
if (doc.doctype && doc.doctype=="dosar" && | |
doc.nume_formular && doc.nume_formular=="BD2012_FORMULAR_UTILIZATOR_NOU"){ | |
emit(null,doc); | |
} | |
}; | |
//aici aduc datele din view | |
$.couch.db("bd2013").query(mapFunction, "", "javascript", { | |
success: function(data) { | |
console.log(data); | |
//aici mai am un view-map | |
var mapFunction = function(doc) { | |
if (doc.doctype && doc.doctype=="dosar" && | |
doc.nume_formular && doc.nume_formular=="BD2012_FORMULAR_UTILIZATOR_NOU"){ | |
emit(null,doc); | |
} | |
}; | |
$.couch.db("bd2013").query(mapFunction, "", "javascript", { | |
//modific datele care imi vin de la server | |
success: function(data) { | |
var i =0; | |
var lenData = data.rows.length; | |
for(i = 0; i< lenData; i++){ | |
var doc = data.rows[i].value; | |
doc.aplicatie = "bd2013"; | |
doc.nume_formular="BD2013_FORMULAR_UTILIZATOR_NOU"; | |
//aici salvez documetul modificat | |
$.couch.db("bd2013").saveDoc(doc, { | |
success: function(data) { | |
console.log(data); | |
}, | |
error: function(status) { | |
console.log(status); | |
} | |
}); | |
}; | |
console.log(data); | |
}, | |
error: function(status) { | |
console.log(status); | |
}, | |
reduce: false | |
}); | |
}, | |
error: function(status) { | |
console.log(status); | |
}, | |
reduce: false | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment