Last active
August 29, 2015 13:57
-
-
Save mattsahr/9795315 to your computer and use it in GitHub Desktop.
DB.info() test
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
<html> | |
<body> | |
<h1>db.info() test</h1> | |
<p>Using pouchdb-3.1.0</p> | |
<p id="putResult"></p> | |
<p id="getResult"></p> | |
<p id="getInfoPrep"></p> | |
<div class="pre-wrap"> | |
<pre id="getInfoResult"></pre> | |
</div> | |
<script type="text/javascript" src="//cdn.jsdelivr.net/pouchdb/3.1.0/pouchdb.min.js"></script> | |
<script src="script.js"></script> | |
<style> | |
.pre-wrap { | |
width: 80%; | |
margin: 10px auto; | |
padding: 20px; | |
border: 2px solid rgb(136, 136, 136); | |
background: rgb(20, 20, 20); | |
color: rgb(255, 255, 255); | |
} | |
</style> | |
</body> | |
</html> | |
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
var db = new PouchDB('testMe'); | |
var getInfo = function () { | |
if (db) { | |
document.getElementById('getInfoPrep').innerHTML = 'Getting Info from ' + db._db_name + ' | adapter: ' + db._adapter; | |
db.info().then(function(info){ | |
document.getElementById('getInfoResult').innerHTML = JSON.stringify(info); | |
}); | |
} | |
}; | |
var putTest = function () { | |
if (db) { | |
db.put({ | |
title: 'Yo Yo Test Me!' | |
}, 'testdoc', function(err, response) { | |
if (err) { console.log('db.put error'); console.log(err); } | |
document.getElementById('putResult').innerHTML = 'put success. id: ' + response.id; | |
}); | |
} | |
}; | |
var getTest = function () { | |
db.get('testdoc', function(err, response) { | |
if (err) { console.log('db.get error'); console.log(err); } | |
document.getElementById('getResult').innerHTML = 'get success. id: ' + response._id + ' | title: '+ response.title; | |
}); | |
}; | |
setTimeout(putTest, 1000); | |
setTimeout(getTest, 2000); | |
setTimeout(getInfo, 3000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment