var i=function(){i=Object.assign||function(o){for(var t,e=1,d=arguments.length;e<d;e++){t=arguments[e];for(var r in t)if(Object.prototype.hasOwnProperty.call(t,r))o[r]=t[r]}return o};return i.apply(this,arguments)};import{DocumentAction as u}from"../common/constant";import{DbBuildError as c}from"../common/error";import{ActionBuilder as a}from"../common/util";import{AggregateBuilder as s}from"./Aggregate";import{DocumentBuilder as f}from"./Document";import{QueryBuilder as n}from"./Query";import{GeoRequest as l}from"../command/GeoRequest";var p=function(){function o(t,e){this.collectionName=t;this.options=i({maxAddCount:200},e)}o.prototype.add=function(t){if(!(t===null||t===void 0?void 0:t.data)){throw c.invalidParam("data","\u4E0D\u80FD\u4E3A\u7A7A")}if(Array.isArray(t.data)){return this.batchAdd(t)}var e=new l(t.data).stringify();return a.buildDocumentAction(u.create,this.collectionName,e)};o.prototype.batchAdd=function(t){if(t.data.length<=0){throw c.invalidParam("data","\u4E0D\u80FD\u4E3A\u7A7A\u6570\u7EC4")}if(t.data.length>this.options.maxAddCount){throw c.invalidParam("data","\u6700\u5927\u957F\u5EA6 ".concat(this.options.maxAddCount))}var e={$create:new l(t.data).stringify()};if(typeof t.ordered==="boolean"){e.$ordered=t.ordered}return a.buildDocumentAction(u.batchCreate,this.collectionName,e)};o.prototype.doc=function(t){return new f(this.collectionName,t)};o.prototype.limit=function(t){return new n(this.collectionName).limit(t)};o.prototype.skip=function(t){return new n(this.collectionName).skip(t)};o.prototype.where=function(t){return new n(this.collectionName).where(t)};o.prototype.projection=function(t){return new n(this.collectionName).projection(t)};o.prototype.orderBy=function(t,e){return new n(this.collectionName).orderBy(t,e)};o.prototype.aggregate=function(){return new s(this.collectionName)};o.prototype.get=function(){return new n(this.collectionName).get()};o.prototype.count=function(){return new n(this.collectionName).count()};return o}();export{p as CollectionBuilder};