當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript pouchdb.put函數代碼示例

本文整理匯總了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) => {
    });
}
開發者ID:Crevil,項目名稱:DefinitelyTyped,代碼行數:57,代碼來源:pouchdb-tests.ts

示例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);
		});
	});
開發者ID:bensbigolbeard,項目名稱:universal-todomvc,代碼行數:14,代碼來源:server-db.ts

示例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)

}
開發者ID:Edward-Lombe,項目名稱:elm-electron,代碼行數:17,代碼來源:main.ts

示例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(){
開發者ID:dottgonzo,項目名稱:express-autoaurora,代碼行數:61,代碼來源:setpowerpartials.ts

示例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)
 }
開發者ID:YanLinAung,項目名稱:kindscript,代碼行數:5,代碼來源:db.ts

示例6: addDocument

addDocument(message) {
  this.db.put(message);
}
開發者ID:ujjwal996,項目名稱:campChatIonic,代碼行數:3,代碼來源:data.ts


注:本文中的pouchdb.put函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。