本文整理汇总了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);
}