Skip to content

Instantly share code, notes, and snippets.

@ronycohen
ronycohen / gist:f74d006c5ccbd4fe46b6
Created April 7, 2015 14:12
relational pouch - use of BulkDocs from a JSON.
multiSave : function(json, type){
console.info("multiSave", type);
json.map(function(obj,i){
console.debug(obj, i);
obj._id = factory.db.rel.makeDocID({ "type": type, "id": i+1 });
});
factory.db.bulkDocs(json).then(function (result) {
console.debug("load ok", result);
// handle result
}).catch(function (err) {
<ion-view title="Relation" cache-view="true" >
<div class="tabs tabs-top tabs-balanced has-subheader">
<a class= "tab-item" ng-class="{'tab-item-active':slideIndex==0}" ng-click="changeSlide(0)">
Echanges
</a>
<a class= "tab-item" ng-class="{'tab-item-active':slideIndex==1}" ng-click="changeSlide(1)">
Infos
</a>
<!-- <a class= "tab-item" ng-class="{'tab-item-active':slideIndex==2}" ng-click="changeSlide(2)">
@ronycohen
ronycohen / Sync Configuration
Last active August 29, 2015 14:25
server side filtering
localDB.sync(remoteDB, options)
==>
options = {
batch_size : 1000,
live: live,
filter: 'app/appfilter',
retry : true,
var stream = window.memorystream;
PouchDB.plugin(replicationStream.plugin); //error here.
console.debug("stream",stream);
$q.all([
pouch.localDB.load(stream), //error here
pouch.remoteDB.dump(stream) // error here
]).then(function (res) {
console.log('stream Hooray the stream replication is complete!', res);
});
{
"_id": "org.couchdb.user:charlotte2",
"_rev": "1-26c282b6db1e1ad8af301b2589dedd28",
"password_scheme": "pbkdf2",
"iterations": 10,
"name": "charlotte2",
"type": "user",
"roles": [
"charlotte2",
"whenagainer"
http://i.snag.gy/eW5dW.jpg
@ronycohen
ronycohen / gist:4392763af97e3d788690
Created October 15, 2015 20:02
error from IOS / SAFARI with Cloudant.
[Error] Failed to load resource: Request header field Authorization is not allowed by Access-Control-Allow-Headers. (email_2_5DD0964D-E433-4D57-8F57-4578039F4C70, line 0)
[Error] XMLHttpRequest cannot load https://myapp.cloudant.com/db(2e)eee(2e)pro(40)aze(2e)com/email_2_5DD0964D-E433-4D57-8F57-4578039F4C70?revs=true&open_revs=[%222-e4d38e9072e9c717b393b19979b80a02%22]. Request header field Authorization is not allowed by Access-Control-Allow-Headers.
[Error] Failed to load resource: The network connection was lost. (_revs_diff, line 0)
[Log] Sync onPause (console-via-logger.js, line 173)
PouchError
[Error] Failed to load resource: Request header field Authorization is not allowed by Access-Control-Allow-Headers. (_changes, line 0)
[Error] XMLHttpRequest cannot load https://myapp.cloudant.com/db(2e)eee(2e)pro(40)aze(2e)com/_changes?timeout=25000&style=all_docs&feed=longpoll&heartbeat=10000&filter=filters%2Fwafilter1&since=4719-g1AAAAEneJzLYWBgYMlgTmGQT0lKzi9KdUhJstTLSs1LLUst0kvOyS9NScwr0ctLLckBKmRKZEiy____
@ronycohen
ronycohen / gist:b81b3ef51290439bceb5
Created October 30, 2015 15:35
error ==> no_usable_index: Database encountered an unknown error
var db = new PouchDB(cloudantURL);
db.createIndex({
index: {
fields: ['_id'],
name: 'addressesIndex',
ddoc: 'addressesddoc',
type: 'json'
}
})
@ronycohen
ronycohen / $OR not working at all
Last active December 7, 2015 16:22
DESIGN DOC
{"$or":[{"name":"james"},{"name":"doe"}]}
root@user:/srv/nodejs/testLevelDown# rm -rf node_modules/
root@user:/srv/nodejs/testLevelDown# npm install leveldown --verbose
npm info it worked if it ends with ok
npm verb cli [ '/usr/local/bin/node',
npm verb cli '/usr/local/bin/npm',
npm verb cli 'install',
npm verb cli 'leveldown',
npm verb cli '--verbose' ]
npm info using npm@3.6.0
npm info using node@v5.6.0