本文整理匯總了TypeScript中pouchdb.put函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript put函數的具體用法?TypeScript put怎麽用?TypeScript put使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了put函數的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: testBasics
function testBasics() {
interface MyModel {
property: 'someProperty ';
}
let model: PouchDB.Core.Document<MyModel>;
const id = 'model';
let db = new PouchDB<MyModel>();
db = new PouchDB<MyModel>(null, {
adapter: 'fruitdown'
});
db = new PouchDB<MyModel>(null, {
adapter: 'http'
});
db = new PouchDB<MyModel>(null, {
adapter: 'idb'
});
db = new PouchDB<MyModel>(null, {
adapter: 'leveldb'
});
db = new PouchDB<MyModel>(null, {
adapter: 'localstorage'
});
db = new PouchDB<MyModel>(null, {
adapter: 'memory'
});
db = new PouchDB<MyModel>(null, {
adapter: 'websql'
});
db = new PouchDB<MyModel>(null, {
adapter: 'websql',
size: 100
});
db.post(model).then((result) => {
isString(result.id);
});
db.post(model, null, (error, response) => {
});
db.get(id).then((result) => model = result);
db.get(id, null, (error, result) => {
});
db.put(model).then((error) => {
});
db.put(model, null, (error) => {
});
db.info().then((info) => {
});
db.info((error, result) => {
});
db.viewCleanup().catch((error) => {
});
}
示例2: function
db.get(req.ip, function (err: any, doc: any) {
let store = configureStore(doc.store);
store.dispatch({ type: req.query.type });
let model = {
_id: doc._id,
_rev: doc._rev,
store: store.getState()
};
db.put(model, function (err: any, doc: any) {
console.log(model.store);
callback(req, res, model.store);
});
});
示例3: testCouchDB
async function testCouchDB() {
const DATABASE_URL = 'http://52.62.108.14:5984/test'
const canGet = await fetch(DATABASE_URL)
console.log(canGet)
const pouchDB = new PouchDB(DATABASE_URL)
const doc = await pouchDB.get('myJam')
Object.assign(doc, { newKey: 'value', time: new Date().toISOString() })
const update = await pouchDB.put(doc)
console.log(doc, update)
}
示例4: resolve
partialsDB.get('daily_'+data.uid).then(function(dayPower){
if( dayPower.dateBeginningOfDay != dateBeginningOfDay ){
let dailynew={
_id:'daily_'+data.uid+'_'+dayPower.dateforDay,
power:dayPower.power,
updatedAt:dayPower.dateBeginningOfDay
};
localDB.put(dailynew).then(function(doc){
console.log(doc)
dayPower.power=data.dailyEnergy;
dayPower.dateBeginningOfDay=dateBeginningOfDay;
dayPower.dateforDay=dateforDay;
partialsDB.destroy().then(function(){
let partialsDB=PouchDB(partialsdb+'_'+data.uid+'_day',{auto_compaction: true});
delete dayPower._rev;
partialsDB.put(dayPower).then(function(){
resolve(true);
}).catch(function(err){
console.log(err,"error","save daily");
reject(err);
});
});
}).catch(function(err){
reject(err);
});
} else{
dayPower.power=data.dailyEnergy;
dayPower.dateBeginningOfDay=dateBeginningOfDay;
dayPower.dateforDay=dateforDay;
partialsDB.destroy().then(function(){
let partialsDB=PouchDB(partialsdb+'_'+data.uid+'_day',{auto_compaction: true});
delete dayPower._rev;
partialsDB.put(dayPower).then(function(){
resolve(true);
}).catch(function(err){
console.log(err,"error","save daily partial");
reject(err);
});
});
}
}).catch(function(){
示例5: setAsync
setAsync(obj:any):Promise<string> {
if (obj.id && !obj._id)
obj._id = this.name + "--" + obj.id
return db.put(obj).then((resp:any) => resp.rev)
}
示例6: addDocument
addDocument(message) {
this.db.put(message);
}