unicloud-db.js.map
23.3 KB
{"version":3,"sources":["webpack:///./node_modules/@dcloudio/uni-cli-shared/components/unicloud-db.vue?a036","webpack:///./node_modules/@dcloudio/uni-cli-shared/components/unicloud-db.vue?a6fb","webpack:///./node_modules/@dcloudio/uni-cli-shared/components/unicloud-db.vue?321a","webpack:///./node_modules/@dcloudio/uni-cli-shared/components/unicloud-db.vue?17d5","webpack:///node_modules/@dcloudio/uni-cli-shared/components/unicloud-db.vue?5078"],"names":[],"mappings":";;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAwH;AACxH;AAC+D;AACL;;;AAG1D;AACyG;AACzG,gBAAgB,0HAAU;AAC1B,EAAE,iFAAM;AACR,EAAE,sFAAM;AACR,EAAE,+FAAe;AACjB;AACA;AACA;AACA;AACA;AACA,EAAE,0FAAU;AACZ;AACA;;AAEA;AACe,gF;;;;;;;;;;;;ACtBf;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;;;;;;;;;;;ACAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;AClBA;AAAA;AAAA;AAAA;AAAmV,CAAgB,+XAAG,EAAC,C;;;;;;;;;;;;;;;;;;;;;;;;;;ACcvW;AACA,kF;;AAEA,yC,CAAA,C,gBAAA,C;;AAEA;AACA,cADA;AAEA,gBAFA;;AAIA;AACA,YADA;AAEA,oBAFA;;AAIA;AACA,cADA;AAEA,oBAFA;AAGA,kBAHA;;;AAMA;AACA,aADA;AAEA,UAFA;AAGA,WAHA;AAIA,YAJA;AAKA,QALA;AAMA,OANA;AAOA,UAPA;AAQA,SARA;AASA,OATA;AAUA,SAVA;AAWA,YAXA;AAYA,UAZA,E;;;AAeA;AACA,oBADA;AAEA;AACA;AACA,2BADA;AAEA,aAFA,sBAEA;AACA;AACA,OAJA,EADA;;AAO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AGA;AACA,KANA,EAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,KA5BA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsEA;AACA;AACA;AACA,GA7MA;;;;;;;;;;;;;;;AA4NA;AACA,YADA,oBACA,KADA,EACA,KADA,EACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAFA,MAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAfA,MAeA;AACA;AACA;;AAEA;AACA,KAxBA;AAyBA,YAzBA,sBAyBA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,KAnCA;AAoCA,WApCA,qBAoCA;AACA;AACA;AACA,KAvCA;AAwCA,SAxCA,mBAwCA;AACA;AACA;AACA,KA3CA;AA4CA,SA5CA,mBA4CA;AACA;AACA,KA9CA;AA+CA,OA/CA,eA+CA,KA/CA;;;;;;;;;;AAyDA,uFATA,MASA,QATA,MASA,uBARA,SAQA,CARA,SAQA,+BARA,IAQA,kBAPA,UAOA,QAPA,UAOA,CANA,OAMA,QANA,OAMA,CALA,IAKA,QALA,IAKA,CAJA,QAIA,QAJA,QAIA,yBAHA,WAGA,CAHA,WAGA,iCAHA,IAGA,4CAFA,WAEA,CAFA,WAEA,iCAFA,IAEA,6CADA,YACA,CADA,YACA,kCADA,EACA;AACA;AACA;AACA,6BADA;;AAGA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,oEADA;;AAGA;AACA,OAPA,EAOA,KAPA,CAOA;AACA;AACA;AACA;AACA,gCADA;AAEA,6BAFA;;AAIA;AACA,OAfA,EAeA,OAfA,CAeA;AACA;AACA;AACA;AACA;AACA,OApBA;AAqBA,KA1FA;AA2FA,UA3FA,kBA2FA,EA3FA;;;;;;;;;;AAqGA,0GATA,MASA,SATA,MASA,CARA,QAQA,SARA,OAQA,CAPA,IAOA,SAPA,IAOA,CANA,QAMA,SANA,QAMA,CALA,YAKA,SALA,YAKA,CAJA,cAIA,SAJA,cAIA,2BAHA,WAGA,CAHA,WAGA,kCAHA,IAGA,+CAFA,WAEA,CAFA,WAEA,kCAFA,IAEA,gDADA,YACA,CADA,YACA,mCADA,EACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,6EADA;AAEA,mFAFA;AAGA,wBAHA;AAIA;AACA;AACA;AACA;AACA;AACA,SATA;;AAWA,KAxHA;AAyHA,UAzHA,kBAyHA,EAzHA,EAyHA,KAzHA;;;;;;;;;;AAmIA,wFATA,MASA,SATA,MASA,yBARA,SAQA,CARA,SAQA,gCARA,IAQA,mBAPA,UAOA,SAPA,UAOA,CANA,OAMA,SANA,OAMA,CALA,IAKA,SALA,IAKA,CAJA,QAIA,SAJA,QAIA,2BAHA,WAGA,CAHA,WAGA,kCAHA,IAGA,+CAFA,WAEA,CAFA,WAEA,kCAFA,IAEA,gDADA,YACA,CADA,YACA,mCADA,EACA;AACA;AACA;AACA,6BADA;;AAGA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,uEADA;;AAGA;AACA,OAPA,EAOA,KAPA,CAOA;AACA;AACA;AACA;AACA,gCADA;AAEA,6BAFA;;AAIA;AACA,OAfA,EAeA,OAfA,CAeA;AACA;AACA;AACA;AACA;AACA,OApBA;AAqBA,KApKA;AAqKA,WArKA,qBAqKA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OA9BA;;;;;AAmCA,6BAnCA,CAiCA,OAjCA,yBAiCA,OAjCA,CAkCA,IAlCA,yBAkCA,IAlCA;AAoCA;AACA;AACA;AACA;AACA;AACA,mCADA;AAEA,iCAFA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AAC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5VA,EA4VA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAtWA;AAuWA,kBAvWA,0BAuWA,IAvWA,EAuWA,IAvWA,EAuWA;AACA;AACA;AACA,OAFA,MAEA;AACA;AACA;AACA,KA7WA,EA5NA,E","file":"node-modules/@dcloudio/uni-cli-shared/components/unicloud-db.js","sourcesContent":["import { render, staticRenderFns, recyclableRender, components } from \"./unicloud-db.vue?vue&type=template&id=c1dc9ea0&\"\nvar renderjs\nimport script from \"./unicloud-db.vue?vue&type=script&lang=js&\"\nexport * from \"./unicloud-db.vue?vue&type=script&lang=js&\"\n\n\n/* normalize component */\nimport normalizer from \"!../../vue-cli-plugin-uni/packages/vue-loader/lib/runtime/componentNormalizer.js\"\nvar component = normalizer(\n script,\n render,\n staticRenderFns,\n false,\n null,\n null,\n null,\n false,\n components,\n renderjs\n)\n\ncomponent.options.__file = \"Program Files/HBuilderX/plugins/uniapp-cli/node_modules/@dcloudio/uni-cli-shared/components/unicloud-db.vue\"\nexport default component.exports","export * from \"-!../../vue-cli-plugin-uni/packages/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!../../vue-cli-plugin-uni/packages/webpack-preprocess-loader/index.js??ref--16-0!../../webpack-uni-mp-loader/lib/template.js!../../vue-cli-plugin-uni/packages/webpack-uni-app-loader/page-meta.js!../../vue-cli-plugin-uni/packages/vue-loader/lib/index.js??vue-loader-options!../../webpack-uni-mp-loader/lib/style.js!./unicloud-db.vue?vue&type=template&id=c1dc9ea0&\"","var components\nvar render = function() {\n var _vm = this\n var _h = _vm.$createElement\n var _c = _vm._self._c || _h\n if (_vm.$scope.data.scopedSlotsCompiler === \"augmented\") {\n _vm.$setScopedSlotsParams(\"default\", {\n options: _vm.options,\n data: _vm.dataList,\n pagination: _vm.paginationInternal,\n loading: _vm.loading,\n hasMore: _vm.hasMore,\n error: _vm.errorMessage\n })\n }\n}\nvar recyclableRender = false\nvar staticRenderFns = []\nrender._withStripped = true\n\nexport { render, staticRenderFns, recyclableRender, components }","import mod from \"-!../../../babel-loader/lib/index.js!../../vue-cli-plugin-uni/packages/webpack-preprocess-loader/index.js??ref--12-1!../../webpack-uni-mp-loader/lib/script.js!../../vue-cli-plugin-uni/packages/vue-loader/lib/index.js??vue-loader-options!../../webpack-uni-mp-loader/lib/style.js!./unicloud-db.vue?vue&type=script&lang=js&\"; export default mod; export * from \"-!../../../babel-loader/lib/index.js!../../vue-cli-plugin-uni/packages/webpack-preprocess-loader/index.js??ref--12-1!../../webpack-uni-mp-loader/lib/script.js!../../vue-cli-plugin-uni/packages/vue-loader/lib/index.js??vue-loader-options!../../webpack-uni-mp-loader/lib/style.js!./unicloud-db.vue?vue&type=script&lang=js&\"","<template>\n <view>\n <slot\n :options=\"options\"\n :data=\"dataList\"\n :pagination=\"paginationInternal\"\n :loading=\"loading\"\n :hasMore=\"hasMore\"\n :error=\"errorMessage\"\n />\n </view>\n</template>\n\n<script>\nimport { initVueI18n } from '@dcloudio/uni-i18n'\nimport messages from './i18n/index'\n\nconst { t } = initVueI18n(messages)\n\nconst events = {\n load: 'load',\n error: 'error'\n}\nconst pageMode = {\n add: 'add',\n replace: 'replace'\n}\nconst loadMode = {\n auto: 'auto',\n onready: 'onready',\n manual: 'manual'\n}\n\nconst attrs = [\n 'pageCurrent',\n 'pageSize',\n 'spaceInfo',\n 'collection',\n 'action',\n 'field',\n 'getcount',\n 'orderby',\n 'where',\n 'groupby',\n 'groupField',\n 'distinct'\n]\n\nexport default {\n name: 'UniClouddb',\n props: {\n options: {\n type: [Object, Array],\n default () {\n return {}\n }\n },\n spaceInfo: {\n type: Object,\n default () {\n return {}\n }\n },\n collection: {\n type: [String, Array],\n default: ''\n },\n action: {\n type: String,\n default: ''\n },\n field: {\n type: String,\n default: ''\n },\n orderby: {\n type: String,\n default: ''\n },\n where: {\n type: [String, Object],\n default: ''\n },\n pageData: {\n type: String,\n default: 'add'\n },\n pageCurrent: {\n type: Number,\n default: 1\n },\n pageSize: {\n type: Number,\n default: 20\n },\n getcount: {\n type: [Boolean, String],\n default: false\n },\n getone: {\n type: [Boolean, String],\n default: false\n },\n gettree: {\n type: [Boolean, String, Object],\n default: false\n },\n gettreepath: {\n type: [Boolean, String],\n default: false\n },\n startwith: {\n type: String,\n default: ''\n },\n limitlevel: {\n type: Number,\n default: 10\n },\n groupby: {\n type: String,\n default: ''\n },\n groupField: {\n type: String,\n default: ''\n },\n distinct: {\n type: [Boolean, String],\n default: false\n },\n pageIndistinct: {\n type: [Boolean, String],\n default: false\n },\n foreignKey: {\n type: String,\n default: ''\n },\n loadtime: {\n type: String,\n default: 'auto'\n },\n manual: {\n type: Boolean,\n default: false\n }\n },\n data () {\n return {\n loading: false,\n hasMore: false,\n dataList: this.getone ? undefined : [],\n paginationInternal: {},\n errorMessage: ''\n }\n },\n computed: {\n collectionArgs () {\n return Array.isArray(this.collection) ? this.collection : [this.collection]\n },\n isLookup () {\n return (Array.isArray(this.collection) && this.collection.length > 1) || (typeof this.collection === 'string' && this.collection.indexOf(',') > -1)\n },\n mainCollection () {\n if (typeof this.collection === 'string') {\n return this.collection.split(',')[0]\n }\n const mainQuery = JSON.parse(JSON.stringify(this.collection[0]))\n return mainQuery.$db[0].$param[0]\n }\n },\n created () {\n this._isEnded = false\n this.paginationInternal = {\n current: this.pageCurrent,\n size: this.pageSize,\n count: 0\n }\n\n this.$watch(() => {\n var al = []\n attrs.forEach(key => {\n al.push(this[key])\n })\n return al\n }, (newValue, oldValue) => {\n this.paginationInternal.size = this.pageSize\n if (newValue[0] !== oldValue[0]) {\n this.paginationInternal.current = this.pageCurrent\n }\n if (this.loadtime === loadMode.manual) {\n return\n }\n\n let needReset = false\n for (let i = 2; i < newValue.length; i++) {\n if (newValue[i] !== oldValue[i]) {\n needReset = true\n break\n }\n }\n if (needReset) {\n this.clear()\n this.reset()\n }\n\n this._execLoadData()\n })\n\n // #ifdef H5\n if (process.env.NODE_ENV === 'development') {\n this._debugDataList = []\n if (!window.unidev) {\n window.unidev = {\n clientDB: {\n data: []\n }\n }\n }\n window.unidev.clientDB.data.push(this._debugDataList)\n }\n // #endif\n\n // #ifdef MP-TOUTIAO\n let changeName\n const events = this.$scope.dataset.eventOpts || []\n for (var i = 0; i < events.length; i++) {\n const event = events[i]\n if (event[0].includes('^load')) {\n changeName = event[1][0][0]\n }\n }\n if (changeName) {\n let parent = this.$parent\n let maxDepth = 16\n this._changeDataFunction = null\n while (parent && maxDepth > 0) {\n const fun = parent[changeName]\n if (fun && typeof fun === 'function') {\n this._changeDataFunction = fun\n maxDepth = 0\n break\n }\n parent = parent.$parent\n maxDepth--\n }\n }\n // #endif\n\n if (!this.manual && this.loadtime === loadMode.auto) {\n this.loadData()\n }\n },\n // #ifdef H5\n beforeDestroy () {\n if (process.env.NODE_ENV === 'development' && window.unidev) {\n var cd = this._debugDataList\n var dl = window.unidev.clientDB.data\n for (var i = dl.length - 1; i >= 0; i--) {\n if (dl[i] === cd) {\n dl.splice(i, 1)\n break\n }\n }\n }\n },\n // #endif\n methods: {\n loadData (args1, args2) {\n let callback = null\n let clear = false\n if (typeof args1 === 'object') {\n if (args1.clear) {\n if (this.pageData === pageMode.replace) {\n this.clear()\n } else {\n clear = args1.clear\n }\n this.reset()\n }\n if (args1.current !== undefined) {\n this.paginationInternal.current = args1.current\n }\n if (typeof args2 === 'function') {\n callback = args2\n }\n } else if (typeof args1 === 'function') {\n callback = args1\n }\n\n this._execLoadData(callback, clear)\n },\n loadMore () {\n if (this._isEnded || this.loading) {\n return\n }\n\n if (this.pageData === pageMode.add) {\n this.paginationInternal.current++\n }\n\n this._execLoadData()\n },\n refresh () {\n this.clear()\n this._execLoadData()\n },\n clear () {\n this._isEnded = false\n this.dataList = []\n },\n reset () {\n this.paginationInternal.current = 1\n },\n add (value, {\n action,\n showToast = true,\n toastTitle,\n success,\n fail,\n complete,\n needConfirm = true,\n needLoading = true,\n loadingTitle = ''\n } = {}) {\n if (needLoading) {\n uni.showLoading({\n title: loadingTitle\n })\n }\n /* eslint-disable no-undef */\n let db = uniCloud.database(this.spaceInfo)\n if (action) {\n db = db.action(action)\n }\n\n db.collection(this.mainCollection).add(value).then((res) => {\n success && success(res)\n if (showToast) {\n uni.showToast({\n title: toastTitle || t('uniCloud.component.add.success')\n })\n }\n }).catch((err) => {\n fail && fail(err)\n if (needConfirm) {\n uni.showModal({\n content: err.message,\n showCancel: false\n })\n }\n }).finally(() => {\n if (needLoading) {\n uni.hideLoading()\n }\n complete && complete()\n })\n },\n remove (id, {\n action,\n success,\n fail,\n complete,\n confirmTitle,\n confirmContent,\n needConfirm = true,\n needLoading = true,\n loadingTitle = ''\n } = {}) {\n if (!id || !id.length) {\n return\n }\n if (!needConfirm) {\n this._execRemove(id, action, success, fail, complete, needConfirm, needLoading, loadingTitle)\n return\n }\n uni.showModal({\n title: confirmTitle || t('uniCloud.component.remove.showModal.title'),\n content: confirmContent || t('uniCloud.component.remove.showModal.content'),\n showCancel: true,\n success: (res) => {\n if (!res.confirm) {\n return\n }\n this._execRemove(id, action, success, fail, complete, needConfirm, needLoading, loadingTitle)\n }\n })\n },\n update (id, value, {\n action,\n showToast = true,\n toastTitle,\n success,\n fail,\n complete,\n needConfirm = true,\n needLoading = true,\n loadingTitle = ''\n } = {}) {\n if (needLoading) {\n uni.showLoading({\n title: loadingTitle\n })\n }\n /* eslint-disable no-undef */\n let db = uniCloud.database(this.spaceInfo)\n if (action) {\n db = db.action(action)\n }\n\n return db.collection(this.mainCollection).doc(id).update(value).then((res) => {\n success && success(res)\n if (showToast) {\n uni.showToast({\n title: toastTitle || t('uniCloud.component.update.success')\n })\n }\n }).catch((err) => {\n fail && fail(err)\n if (needConfirm) {\n uni.showModal({\n content: err.message,\n showCancel: false\n })\n }\n }).finally(() => {\n if (needLoading) {\n uni.hideLoading()\n }\n complete && complete()\n })\n },\n getTemp (isTemp = true) {\n /* eslint-disable no-undef */\n let db = uniCloud.database(this.spaceInfo)\n\n if (this.action) {\n db = db.action(this.action)\n }\n\n db = db.collection(...this.collectionArgs)\n\n if (this.foreignKey) {\n db = db.foreignKey(this.foreignKey)\n }\n if (!(!this.where || !Object.keys(this.where).length)) {\n db = db.where(this.where)\n }\n if (this.field) {\n db = db.field(this.field)\n }\n if (this.groupby) {\n db = db.groupBy(this.groupby)\n }\n if (this.groupField) {\n db = db.groupField(this.groupField)\n }\n if (this.distinct === true) {\n db = db.distinct()\n }\n if (this.orderby) {\n db = db.orderBy(this.orderby)\n }\n\n const {\n current,\n size\n } = this.paginationInternal\n const getOptions = {}\n if (this.getcount) {\n getOptions.getCount = this.getcount\n }\n const treeOptions = {\n limitLevel: this.limitlevel,\n startWith: this.startwith\n }\n if (this.gettree) {\n getOptions.getTree = treeOptions\n }\n if (this.gettreepath) {\n getOptions.getTreePath = treeOptions\n }\n db = db.skip(size * (current - 1)).limit(size)\n\n if (isTemp) {\n db = db.getTemp(getOptions)\n db.udb = this\n } else {\n db = db.get(getOptions)\n }\n\n return db\n },\n setResult (result) {\n if (result.code === 0) {\n this._execLoadDataSuccess(result)\n } else {\n this._execLoadDataFail(new Error(result.message))\n }\n },\n _execLoadData (callback, clear) {\n if (this.loading) {\n return\n }\n this.loading = true\n this.errorMessage = ''\n\n this._getExec().then((res) => {\n this.loading = false\n this._execLoadDataSuccess(res.result, callback, clear)\n\n // #ifdef H5\n if (process.env.NODE_ENV === 'development') {\n this._debugDataList.length = 0\n const formatData = JSON.parse(JSON.stringify(this.dataList))\n if (Array.isArray(this.dataList)) {\n this._debugDataList.push(...formatData)\n } else {\n this._debugDataList.push(formatData)\n }\n }\n // #endif\n }).catch((err) => {\n this.loading = false\n this._execLoadDataFail(err, callback)\n })\n },\n _execLoadDataSuccess (result, callback, clear) {\n const {\n data,\n count\n } = result\n this._isEnded = count !== undefined ? (this.paginationInternal.current * this.paginationInternal.size >= count) : (data.length < this.pageSize)\n this.hasMore = !this._isEnded\n\n const data2 = this.getone ? (data.length ? data[0] : undefined) : data\n\n if (this.getcount) {\n this.paginationInternal.count = count\n }\n\n callback && callback(data2, this._isEnded, this.paginationInternal)\n this._dispatchEvent(events.load, data2)\n\n if (this.getone || this.pageData === pageMode.replace) {\n this.dataList = data2\n } else {\n if (clear) {\n this.dataList = data2\n } else {\n this.dataList.push(...data2)\n }\n }\n },\n _execLoadDataFail (err, callback) {\n this.errorMessage = err\n callback && callback()\n this.$emit(events.error, err)\n if (process.env.NODE_ENV === 'development') {\n console.error(err)\n }\n },\n _getExec () {\n return this.getTemp(false)\n },\n _execRemove (id, action, success, fail, complete, needConfirm, needLoading, loadingTitle) {\n if (!this.collection || !id) {\n return\n }\n\n const ids = Array.isArray(id) ? id : [id]\n if (!ids.length) {\n return\n }\n\n if (needLoading) {\n uni.showLoading({\n mask: true,\n title: loadingTitle\n })\n }\n\n /* eslint-disable no-undef */\n const db = uniCloud.database(this.spaceInfo)\n const dbCmd = db.command\n\n let exec = db\n if (action) {\n exec = exec.action(action)\n }\n\n exec.collection(this.mainCollection).where({\n _id: dbCmd.in(ids)\n }).remove().then((res) => {\n success && success(res.result)\n if (this.pageData === pageMode.replace) {\n this.refresh()\n } else {\n this.removeData(ids)\n }\n }).catch((err) => {\n fail && fail(err)\n if (needConfirm) {\n uni.showModal({\n content: err.message,\n showCancel: false\n })\n }\n }).finally(() => {\n if (needLoading) {\n uni.hideLoading()\n }\n complete && complete()\n })\n },\n removeData (ids) {\n const il = ids.slice(0)\n const dl = this.dataList\n for (let i = dl.length - 1; i >= 0; i--) {\n const index = il.indexOf(dl[i]._id)\n if (index >= 0) {\n dl.splice(i, 1)\n il.splice(index, 1)\n }\n }\n },\n _dispatchEvent (type, data) {\n if (this._changeDataFunction) {\n this._changeDataFunction(data, this._isEnded, this.paginationInternal)\n } else {\n this.$emit(type, data, this._isEnded, this.paginationInternal)\n }\n }\n }\n}\n</script>\n"],"sourceRoot":""}