var l=function(i,r,t,o){var u=arguments.length,e=u<3?r:o===null?o=Object.getOwnPropertyDescriptor(r,t):o,c;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")e=Reflect.decorate(i,r,t,o);else for(var f=i.length-1;f>=0;f--)if(c=i[f])e=(u<3?c(e):u>3?c(r,t,e):c(r,t))||e;return u>3&&e&&Object.defineProperty(r,t,e),e};var s=function(i,r){if(typeof Reflect==="object"&&typeof Reflect.metadata==="function")return Reflect.metadata(i,r)};var p=function(i,r,t,o){function u(e){return e instanceof t?e:new t(function(c){c(e)})}return new(t||(t=Promise))(function(e,c){function f(a){try{n(o.next(a))}catch(b){c(b)}}function y(a){try{n(o["throw"](a))}catch(b){c(b)}}function n(a){a.done?e(a.value):u(a.value).then(f,y)}n((o=o.apply(i,r||[])).next())})};var h=function(i,r){var t={label:0,sent:function(){if(e[0]&1)throw e[1];return e[1]},trys:[],ops:[]},o,u,e,c=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return c.next=f(0),c["throw"]=f(1),c["return"]=f(2),typeof Symbol==="function"&&(c[Symbol.iterator]=function(){return this}),c;function f(n){return function(a){return y([n,a])}}function y(n){if(o)throw new TypeError("Generator is already executing.");while(c&&(c=0,n[0]&&(t=0)),t)try{if(o=1,u&&(e=n[0]&2?u["return"]:n[0]?u["throw"]||((e=u["return"])&&e.call(u),0):u.next)&&!(e=e.call(u,n[1])).done)return e;if(u=0,e)n=[n[0]&2,e.value];switch(n[0]){case 0:case 1:e=n;break;case 4:t.label++;return{value:n[1],done:false};case 5:t.label++;u=n[1];n=[0];continue;case 7:n=t.ops.pop();t.trys.pop();continue;default:if(!(e=t.trys,e=e.length>0&&e[e.length-1])&&(n[0]===6||n[0]===2)){t=0;continue}if(n[0]===3&&(!e||n[1]>e[0]&&n[1]<e[3])){t.label=n[1];break}if(n[0]===6&&t.label<e[1]){t.label=e[1];e=n;break}if(e&&t.label<e[2]){t.label=e[2];t.ops.push(n);break}if(e[2])t.ops.pop();t.trys.pop();continue}n=r.call(i,t)}catch(a){n=[6,a];u=0}finally{o=e=0}if(n[0]&5)throw n[1];return{value:n[0]?n[1]:void 0,done:true}}};import{WrapCallback as d}from"../decorator";import{FaasError as m}from"../error";import{Query as v}from"./Query";var g=function(){function i(r,t,o){this.collectionName=r;this.id=t;this.options=o}i.prototype.projection=function(r){this.query.projection(r);return this};i.prototype.field=function(r){this.query.field(r);return this};i.prototype.update=function(r){return p(this,void 0,void 0,function(){return h(this,function(t){switch(t.label){case 0:return[4,this.query.update(r)];case 1:return[2,t.sent()]}})})};i.prototype.updateAndReturn=function(r){return p(this,void 0,void 0,function(){return h(this,function(t){switch(t.label){case 0:return[4,this.query.updateAndReturn(r)];case 1:return[2,t.sent()]}})})};i.prototype.set=function(r){return p(this,void 0,void 0,function(){return h(this,function(t){switch(t.label){case 0:return[4,this.query.set(r)];case 1:return[2,t.sent()]}})})};i.prototype.remove=function(){return p(this,void 0,void 0,function(){return h(this,function(r){switch(r.label){case 0:return[4,this.query.remove()];case 1:return[2,r.sent()]}})})};i.prototype.get=function(){return p(this,void 0,void 0,function(){var r,t;return h(this,function(o){switch(o.label){case 0:return[4,this.query.get()];case 1:r=o.sent();t=r[0];if(!t){if(this.options.throwOnNotFound){throw m.NOT_FOUND_ERR("\u4E0D\u5B58\u5728_id \u4E3A ".concat(this.id," \u7684\u6587\u6863"))}return[2,null]}return[2,t]}})})};Object.defineProperty(i.prototype,"query",{get:function(){if(!this._query){this._query=new v(this.collectionName,this.options).where({_id:String(this.id)}).limit(1)}return this._query},enumerable:false,configurable:true});l([d(),s("design:type",Function),s("design:paramtypes",[Object]),s("design:returntype",Promise)],i.prototype,"update",null);l([d(),s("design:type",Function),s("design:paramtypes",[Object]),s("design:returntype",Promise)],i.prototype,"updateAndReturn",null);l([d(),s("design:type",Function),s("design:paramtypes",[Object]),s("design:returntype",Promise)],i.prototype,"set",null);l([d(),s("design:type",Function),s("design:paramtypes",[]),s("design:returntype",Promise)],i.prototype,"remove",null);l([d(),s("design:type",Function),s("design:paramtypes",[]),s("design:returntype",Promise)],i.prototype,"get",null);return i}();export{g as Document};