From 730a2e2814d76382674131c1f71d8e17c307f4e3 Mon Sep 17 00:00:00 2001 From: yoshinorin Date: Mon, 15 Jul 2024 21:21:07 +0000 Subject: [PATCH] deploy: 6618b09880f54e3800755551c08b7facf22501de --- assets/main.js | 8 +- assets/navigation.js | 2 +- assets/style.css | 10 + classes/database.default.html | 10 +- classes/document.default.html | 18 +- classes/error.default.html | 4 +- classes/error_population.default.html | 4 +- classes/error_validation.default.html | 4 +- classes/model.default.html | 82 +- classes/mutex.default.html | 4 +- classes/query.default.html | 58 +- classes/schema.default.html | 18 +- classes/schematype.default.html | 44 +- classes/types_array.default.html | 72 +- classes/types_boolean.default.html | 44 +- classes/types_buffer.default.html | 48 +- classes/types_cuid.default.html | 44 +- classes/types_date.default.html | 60 +- classes/types_enum.default.html | 44 +- classes/types_integer.default.html | 58 +- classes/types_number.default.html | 60 +- classes/types_object.default.html | 44 +- classes/types_string.default.html | 48 +- classes/types_virtual.default.html | 48 +- functions/lib_jsonstream.parse.html | 2 +- functions/util.arr2obj.html | 2 +- functions/util.delProp.html | 2 +- functions/util.getProp.html | 2 +- functions/util.parseArgs.html | 2 +- functions/util.reverse.html | 2 +- functions/util.setGetter.html | 2 +- functions/util.setProp.html | 2 +- functions/util.shuffle.html | 2 +- hierarchy.html | 2 +- index.html | 4 +- .../types-1.AddSchemaTypeLoopOptions.html | 2 +- interfaces/types-1.Options.html | 4 +- media/scripts/database.ts | 121 -- media/scripts/document.ts | 131 -- media/scripts/model.ts | 1350 ----------------- media/scripts/mutex.ts | 32 - media/scripts/query.ts | 671 -------- media/scripts/schema.ts | 162 -- media/scripts/schematype.ts | 144 -- media/scripts/types/array.ts | 179 --- media/scripts/types/boolean.ts | 59 - media/scripts/types/buffer.ts | 91 -- media/scripts/types/cuid.ts | 26 - media/scripts/types/date.ts | 97 -- media/scripts/types/enum.ts | 20 - media/scripts/types/integer.ts | 45 - media/scripts/types/number.ts | 78 - media/scripts/types/object.ts | 11 - media/scripts/types/string.ts | 83 - media/scripts/types/virtual.ts | 57 - media/scripts/util.ts | 180 --- modules/database.html | 4 +- modules/document.html | 4 +- modules/error.html | 4 +- modules/error_population.html | 4 +- modules/error_validation.html | 4 +- modules/lib_jsonstream.html | 4 +- modules/model.html | 4 +- modules/mutex.html | 4 +- modules/query.html | 4 +- modules/schema.html | 4 +- modules/schematype.html | 4 +- modules/types-1.html | 4 +- modules/types.html | 4 +- modules/types_array.html | 4 +- modules/types_boolean.html | 4 +- modules/types_buffer.html | 4 +- modules/types_cuid.html | 4 +- modules/types_date.html | 4 +- modules/types_enum.html | 4 +- modules/types_integer.html | 4 +- modules/types_number.html | 4 +- modules/types_object.html | 4 +- modules/types_string.html | 4 +- modules/types_virtual.html | 4 +- modules/util.html | 4 +- types/types-1.AddSchemaTypeMixedOptions.html | 2 +- types/types-1.AddSchemaTypeOptions.html | 2 +- types/types-1.AddSchemaTypeSimpleOptions.html | 2 +- types/types-1.NodeJSLikeCallback.html | 2 +- types/types-1.PopulateResult.html | 2 +- types/types-1.SchemaTypeOptions.html | 2 +- 87 files changed, 494 insertions(+), 4021 deletions(-) delete mode 100644 media/scripts/database.ts delete mode 100644 media/scripts/document.ts delete mode 100644 media/scripts/model.ts delete mode 100644 media/scripts/mutex.ts delete mode 100644 media/scripts/query.ts delete mode 100644 media/scripts/schema.ts delete mode 100644 media/scripts/schematype.ts delete mode 100644 media/scripts/types/array.ts delete mode 100644 media/scripts/types/boolean.ts delete mode 100644 media/scripts/types/buffer.ts delete mode 100644 media/scripts/types/cuid.ts delete mode 100644 media/scripts/types/date.ts delete mode 100644 media/scripts/types/enum.ts delete mode 100644 media/scripts/types/integer.ts delete mode 100644 media/scripts/types/number.ts delete mode 100644 media/scripts/types/object.ts delete mode 100644 media/scripts/types/string.ts delete mode 100644 media/scripts/types/virtual.ts delete mode 100644 media/scripts/util.ts diff --git a/assets/main.js b/assets/main.js index 7d7f77a0..35728810 100644 --- a/assets/main.js +++ b/assets/main.js @@ -1,9 +1,9 @@ "use strict"; window.translations={"copy":"Copy","copied":"Copied!","normally_hidden":"This member is normally hidden due to your filter settings."}; -"use strict";(()=>{var Ce=Object.create;var ie=Object.defineProperty;var Oe=Object.getOwnPropertyDescriptor;var _e=Object.getOwnPropertyNames;var Re=Object.getPrototypeOf,Me=Object.prototype.hasOwnProperty;var Fe=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var De=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of _e(e))!Me.call(t,i)&&i!==n&&ie(t,i,{get:()=>e[i],enumerable:!(r=Oe(e,i))||r.enumerable});return t};var Ae=(t,e,n)=>(n=t!=null?Ce(Re(t)):{},De(e||!t||!t.__esModule?ie(n,"default",{value:t,enumerable:!0}):n,t));var ue=Fe((ae,le)=>{(function(){var t=function(e){var n=new t.Builder;return n.pipeline.add(t.trimmer,t.stopWordFilter,t.stemmer),n.searchPipeline.add(t.stemmer),e.call(n,n),n.build()};t.version="2.3.9";t.utils={},t.utils.warn=function(e){return function(n){e.console&&console.warn&&console.warn(n)}}(this),t.utils.asString=function(e){return e==null?"":e.toString()},t.utils.clone=function(e){if(e==null)return e;for(var n=Object.create(null),r=Object.keys(e),i=0;i0){var d=t.utils.clone(n)||{};d.position=[a,u],d.index=s.length,s.push(new t.Token(r.slice(a,o),d))}a=o+1}}return s},t.tokenizer.separator=/[\s\-]+/;t.Pipeline=function(){this._stack=[]},t.Pipeline.registeredFunctions=Object.create(null),t.Pipeline.registerFunction=function(e,n){n in this.registeredFunctions&&t.utils.warn("Overwriting existing registered function: "+n),e.label=n,t.Pipeline.registeredFunctions[e.label]=e},t.Pipeline.warnIfFunctionNotRegistered=function(e){var n=e.label&&e.label in this.registeredFunctions;n||t.utils.warn(`Function is not registered with pipeline. This may cause problems when serialising the index. -`,e)},t.Pipeline.load=function(e){var n=new t.Pipeline;return e.forEach(function(r){var i=t.Pipeline.registeredFunctions[r];if(i)n.add(i);else throw new Error("Cannot load unregistered function: "+r)}),n},t.Pipeline.prototype.add=function(){var e=Array.prototype.slice.call(arguments);e.forEach(function(n){t.Pipeline.warnIfFunctionNotRegistered(n),this._stack.push(n)},this)},t.Pipeline.prototype.after=function(e,n){t.Pipeline.warnIfFunctionNotRegistered(n);var r=this._stack.indexOf(e);if(r==-1)throw new Error("Cannot find existingFn");r=r+1,this._stack.splice(r,0,n)},t.Pipeline.prototype.before=function(e,n){t.Pipeline.warnIfFunctionNotRegistered(n);var r=this._stack.indexOf(e);if(r==-1)throw new Error("Cannot find existingFn");this._stack.splice(r,0,n)},t.Pipeline.prototype.remove=function(e){var n=this._stack.indexOf(e);n!=-1&&this._stack.splice(n,1)},t.Pipeline.prototype.run=function(e){for(var n=this._stack.length,r=0;r1&&(oe&&(r=s),o!=e);)i=r-n,s=n+Math.floor(i/2),o=this.elements[s*2];if(o==e||o>e)return s*2;if(ol?d+=2:a==l&&(n+=r[u+1]*i[d+1],u+=2,d+=2);return n},t.Vector.prototype.similarity=function(e){return this.dot(e)/this.magnitude()||0},t.Vector.prototype.toArray=function(){for(var e=new Array(this.elements.length/2),n=1,r=0;n0){var o=s.str.charAt(0),a;o in s.node.edges?a=s.node.edges[o]:(a=new t.TokenSet,s.node.edges[o]=a),s.str.length==1&&(a.final=!0),i.push({node:a,editsRemaining:s.editsRemaining,str:s.str.slice(1)})}if(s.editsRemaining!=0){if("*"in s.node.edges)var l=s.node.edges["*"];else{var l=new t.TokenSet;s.node.edges["*"]=l}if(s.str.length==0&&(l.final=!0),i.push({node:l,editsRemaining:s.editsRemaining-1,str:s.str}),s.str.length>1&&i.push({node:s.node,editsRemaining:s.editsRemaining-1,str:s.str.slice(1)}),s.str.length==1&&(s.node.final=!0),s.str.length>=1){if("*"in s.node.edges)var u=s.node.edges["*"];else{var u=new t.TokenSet;s.node.edges["*"]=u}s.str.length==1&&(u.final=!0),i.push({node:u,editsRemaining:s.editsRemaining-1,str:s.str.slice(1)})}if(s.str.length>1){var d=s.str.charAt(0),m=s.str.charAt(1),p;m in s.node.edges?p=s.node.edges[m]:(p=new t.TokenSet,s.node.edges[m]=p),s.str.length==1&&(p.final=!0),i.push({node:p,editsRemaining:s.editsRemaining-1,str:d+s.str.slice(2)})}}}return r},t.TokenSet.fromString=function(e){for(var n=new t.TokenSet,r=n,i=0,s=e.length;i=e;n--){var r=this.uncheckedNodes[n],i=r.child.toString();i in this.minimizedNodes?r.parent.edges[r.char]=this.minimizedNodes[i]:(r.child._str=i,this.minimizedNodes[i]=r.child),this.uncheckedNodes.pop()}};t.Index=function(e){this.invertedIndex=e.invertedIndex,this.fieldVectors=e.fieldVectors,this.tokenSet=e.tokenSet,this.fields=e.fields,this.pipeline=e.pipeline},t.Index.prototype.search=function(e){return this.query(function(n){var r=new t.QueryParser(e,n);r.parse()})},t.Index.prototype.query=function(e){for(var n=new t.Query(this.fields),r=Object.create(null),i=Object.create(null),s=Object.create(null),o=Object.create(null),a=Object.create(null),l=0;l1?this._b=1:this._b=e},t.Builder.prototype.k1=function(e){this._k1=e},t.Builder.prototype.add=function(e,n){var r=e[this._ref],i=Object.keys(this._fields);this._documents[r]=n||{},this.documentCount+=1;for(var s=0;s=this.length)return t.QueryLexer.EOS;var e=this.str.charAt(this.pos);return this.pos+=1,e},t.QueryLexer.prototype.width=function(){return this.pos-this.start},t.QueryLexer.prototype.ignore=function(){this.start==this.pos&&(this.pos+=1),this.start=this.pos},t.QueryLexer.prototype.backup=function(){this.pos-=1},t.QueryLexer.prototype.acceptDigitRun=function(){var e,n;do e=this.next(),n=e.charCodeAt(0);while(n>47&&n<58);e!=t.QueryLexer.EOS&&this.backup()},t.QueryLexer.prototype.more=function(){return this.pos1&&(e.backup(),e.emit(t.QueryLexer.TERM)),e.ignore(),e.more())return t.QueryLexer.lexText},t.QueryLexer.lexEditDistance=function(e){return e.ignore(),e.acceptDigitRun(),e.emit(t.QueryLexer.EDIT_DISTANCE),t.QueryLexer.lexText},t.QueryLexer.lexBoost=function(e){return e.ignore(),e.acceptDigitRun(),e.emit(t.QueryLexer.BOOST),t.QueryLexer.lexText},t.QueryLexer.lexEOS=function(e){e.width()>0&&e.emit(t.QueryLexer.TERM)},t.QueryLexer.termSeparator=t.tokenizer.separator,t.QueryLexer.lexText=function(e){for(;;){var n=e.next();if(n==t.QueryLexer.EOS)return t.QueryLexer.lexEOS;if(n.charCodeAt(0)==92){e.escapeCharacter();continue}if(n==":")return t.QueryLexer.lexField;if(n=="~")return e.backup(),e.width()>0&&e.emit(t.QueryLexer.TERM),t.QueryLexer.lexEditDistance;if(n=="^")return e.backup(),e.width()>0&&e.emit(t.QueryLexer.TERM),t.QueryLexer.lexBoost;if(n=="+"&&e.width()===1||n=="-"&&e.width()===1)return e.emit(t.QueryLexer.PRESENCE),t.QueryLexer.lexText;if(n.match(t.QueryLexer.termSeparator))return t.QueryLexer.lexTerm}},t.QueryParser=function(e,n){this.lexer=new t.QueryLexer(e),this.query=n,this.currentClause={},this.lexemeIdx=0},t.QueryParser.prototype.parse=function(){this.lexer.run(),this.lexemes=this.lexer.lexemes;for(var e=t.QueryParser.parseClause;e;)e=e(this);return this.query},t.QueryParser.prototype.peekLexeme=function(){return this.lexemes[this.lexemeIdx]},t.QueryParser.prototype.consumeLexeme=function(){var e=this.peekLexeme();return this.lexemeIdx+=1,e},t.QueryParser.prototype.nextClause=function(){var e=this.currentClause;this.query.clause(e),this.currentClause={}},t.QueryParser.parseClause=function(e){var n=e.peekLexeme();if(n!=null)switch(n.type){case t.QueryLexer.PRESENCE:return t.QueryParser.parsePresence;case t.QueryLexer.FIELD:return t.QueryParser.parseField;case t.QueryLexer.TERM:return t.QueryParser.parseTerm;default:var r="expected either a field or a term, found "+n.type;throw n.str.length>=1&&(r+=" with value '"+n.str+"'"),new t.QueryParseError(r,n.start,n.end)}},t.QueryParser.parsePresence=function(e){var n=e.consumeLexeme();if(n!=null){switch(n.str){case"-":e.currentClause.presence=t.Query.presence.PROHIBITED;break;case"+":e.currentClause.presence=t.Query.presence.REQUIRED;break;default:var r="unrecognised presence operator'"+n.str+"'";throw new t.QueryParseError(r,n.start,n.end)}var i=e.peekLexeme();if(i==null){var r="expecting term or field, found nothing";throw new t.QueryParseError(r,n.start,n.end)}switch(i.type){case t.QueryLexer.FIELD:return t.QueryParser.parseField;case t.QueryLexer.TERM:return t.QueryParser.parseTerm;default:var r="expecting term or field, found '"+i.type+"'";throw new t.QueryParseError(r,i.start,i.end)}}},t.QueryParser.parseField=function(e){var n=e.consumeLexeme();if(n!=null){if(e.query.allFields.indexOf(n.str)==-1){var r=e.query.allFields.map(function(o){return"'"+o+"'"}).join(", "),i="unrecognised field '"+n.str+"', possible fields: "+r;throw new t.QueryParseError(i,n.start,n.end)}e.currentClause.fields=[n.str];var s=e.peekLexeme();if(s==null){var i="expecting term, found nothing";throw new t.QueryParseError(i,n.start,n.end)}switch(s.type){case t.QueryLexer.TERM:return t.QueryParser.parseTerm;default:var i="expecting term, found '"+s.type+"'";throw new t.QueryParseError(i,s.start,s.end)}}},t.QueryParser.parseTerm=function(e){var n=e.consumeLexeme();if(n!=null){e.currentClause.term=n.str.toLowerCase(),n.str.indexOf("*")!=-1&&(e.currentClause.usePipeline=!1);var r=e.peekLexeme();if(r==null){e.nextClause();return}switch(r.type){case t.QueryLexer.TERM:return e.nextClause(),t.QueryParser.parseTerm;case t.QueryLexer.FIELD:return e.nextClause(),t.QueryParser.parseField;case t.QueryLexer.EDIT_DISTANCE:return t.QueryParser.parseEditDistance;case t.QueryLexer.BOOST:return t.QueryParser.parseBoost;case t.QueryLexer.PRESENCE:return e.nextClause(),t.QueryParser.parsePresence;default:var i="Unexpected lexeme type '"+r.type+"'";throw new t.QueryParseError(i,r.start,r.end)}}},t.QueryParser.parseEditDistance=function(e){var n=e.consumeLexeme();if(n!=null){var r=parseInt(n.str,10);if(isNaN(r)){var i="edit distance must be numeric";throw new t.QueryParseError(i,n.start,n.end)}e.currentClause.editDistance=r;var s=e.peekLexeme();if(s==null){e.nextClause();return}switch(s.type){case t.QueryLexer.TERM:return e.nextClause(),t.QueryParser.parseTerm;case t.QueryLexer.FIELD:return e.nextClause(),t.QueryParser.parseField;case t.QueryLexer.EDIT_DISTANCE:return t.QueryParser.parseEditDistance;case t.QueryLexer.BOOST:return t.QueryParser.parseBoost;case t.QueryLexer.PRESENCE:return e.nextClause(),t.QueryParser.parsePresence;default:var i="Unexpected lexeme type '"+s.type+"'";throw new t.QueryParseError(i,s.start,s.end)}}},t.QueryParser.parseBoost=function(e){var n=e.consumeLexeme();if(n!=null){var r=parseInt(n.str,10);if(isNaN(r)){var i="boost must be numeric";throw new t.QueryParseError(i,n.start,n.end)}e.currentClause.boost=r;var s=e.peekLexeme();if(s==null){e.nextClause();return}switch(s.type){case t.QueryLexer.TERM:return e.nextClause(),t.QueryParser.parseTerm;case t.QueryLexer.FIELD:return e.nextClause(),t.QueryParser.parseField;case t.QueryLexer.EDIT_DISTANCE:return t.QueryParser.parseEditDistance;case t.QueryLexer.BOOST:return t.QueryParser.parseBoost;case t.QueryLexer.PRESENCE:return e.nextClause(),t.QueryParser.parsePresence;default:var i="Unexpected lexeme type '"+s.type+"'";throw new t.QueryParseError(i,s.start,s.end)}}},function(e,n){typeof define=="function"&&define.amd?define(n):typeof ae=="object"?le.exports=n():e.lunr=n()}(this,function(){return t})})()});var se=[];function G(t,e){se.push({selector:e,constructor:t})}var U=class{constructor(){this.alwaysVisibleMember=null;this.createComponents(document.body),this.ensureFocusedElementVisible(),this.listenForCodeCopies(),window.addEventListener("hashchange",()=>this.ensureFocusedElementVisible()),document.body.style.display||(this.ensureFocusedElementVisible(),this.updateIndexVisibility(),this.scrollToHash())}createComponents(e){se.forEach(n=>{e.querySelectorAll(n.selector).forEach(r=>{r.dataset.hasInstance||(new n.constructor({el:r,app:this}),r.dataset.hasInstance=String(!0))})})}filterChanged(){this.ensureFocusedElementVisible()}showPage(){document.body.style.display&&(document.body.style.removeProperty("display"),this.ensureFocusedElementVisible(),this.updateIndexVisibility(),this.scrollToHash())}scrollToHash(){if(location.hash){let e=document.getElementById(location.hash.substring(1));if(!e)return;e.scrollIntoView({behavior:"instant",block:"start"})}}ensureActivePageVisible(){let e=document.querySelector(".tsd-navigation .current"),n=e?.parentElement;for(;n&&!n.classList.contains(".tsd-navigation");)n instanceof HTMLDetailsElement&&(n.open=!0),n=n.parentElement;if(e&&!e.checkVisibility()){let r=e.getBoundingClientRect().top-document.documentElement.clientHeight/4;document.querySelector(".site-menu").scrollTop=r}}updateIndexVisibility(){let e=document.querySelector(".tsd-index-content"),n=e?.open;e&&(e.open=!0),document.querySelectorAll(".tsd-index-section").forEach(r=>{r.style.display="block";let i=Array.from(r.querySelectorAll(".tsd-index-link")).every(s=>s.offsetParent==null);r.style.display=i?"none":"block"}),e&&(e.open=n)}ensureFocusedElementVisible(){if(this.alwaysVisibleMember&&(this.alwaysVisibleMember.classList.remove("always-visible"),this.alwaysVisibleMember.firstElementChild.remove(),this.alwaysVisibleMember=null),!location.hash)return;let e=document.getElementById(location.hash.substring(1));if(!e)return;let n=e.parentElement;for(;n&&n.tagName!=="SECTION";)n=n.parentElement;if(!n)return;let r=n.offsetParent==null,i=n;for(;i!==document.body;)i instanceof HTMLDetailsElement&&(i.open=!0),i=i.parentElement;if(n.offsetParent==null){this.alwaysVisibleMember=n,n.classList.add("always-visible");let s=document.createElement("p");s.classList.add("warning"),s.textContent=window.translations.normally_hidden,n.prepend(s)}r&&e.scrollIntoView()}listenForCodeCopies(){document.querySelectorAll("pre > button").forEach(e=>{let n;e.addEventListener("click",()=>{e.previousElementSibling instanceof HTMLElement&&navigator.clipboard.writeText(e.previousElementSibling.innerText.trim()),e.textContent=window.translations.copied,e.classList.add("visible"),clearTimeout(n),n=setTimeout(()=>{e.classList.remove("visible"),n=setTimeout(()=>{e.textContent=window.translations.copy},100)},1e3)})})}};var oe=(t,e=100)=>{let n;return()=>{clearTimeout(n),n=setTimeout(()=>t(),e)}};var pe=Ae(ue());async function ce(t,e){if(!window.searchData)return;let n=await fetch(window.searchData),r=new Blob([await n.arrayBuffer()]).stream().pipeThrough(new DecompressionStream("gzip")),i=await new Response(r).json();t.data=i,t.index=pe.Index.load(i.index),e.classList.remove("loading"),e.classList.add("ready")}function fe(){let t=document.getElementById("tsd-search");if(!t)return;let e={base:t.dataset.base+"/"},n=document.getElementById("tsd-search-script");t.classList.add("loading"),n&&(n.addEventListener("error",()=>{t.classList.remove("loading"),t.classList.add("failure")}),n.addEventListener("load",()=>{ce(e,t)}),ce(e,t));let r=document.querySelector("#tsd-search input"),i=document.querySelector("#tsd-search .results");if(!r||!i)throw new Error("The input field or the result list wrapper was not found");i.addEventListener("mouseup",()=>{te(t)}),r.addEventListener("focus",()=>t.classList.add("has-focus")),Ve(t,i,r,e)}function Ve(t,e,n,r){n.addEventListener("input",oe(()=>{Ne(t,e,n,r)},200)),n.addEventListener("keydown",i=>{i.key=="Enter"?He(e,t):i.key=="ArrowUp"?(de(e,n,-1),i.preventDefault()):i.key==="ArrowDown"&&(de(e,n,1),i.preventDefault())}),document.body.addEventListener("keypress",i=>{i.altKey||i.ctrlKey||i.metaKey||!n.matches(":focus")&&i.key==="/"&&(i.preventDefault(),n.focus())}),document.body.addEventListener("keyup",i=>{t.classList.contains("has-focus")&&(i.key==="Escape"||!e.matches(":focus-within")&&!n.matches(":focus"))&&(n.blur(),te(t))})}function te(t){t.classList.remove("has-focus")}function Ne(t,e,n,r){if(!r.index||!r.data)return;e.textContent="";let i=n.value.trim(),s;if(i){let o=i.split(" ").map(a=>a.length?`*${a}*`:"").join(" ");s=r.index.search(o)}else s=[];for(let o=0;oa.score-o.score);for(let o=0,a=Math.min(10,s.length);o`,d=he(l.name,i);globalThis.DEBUG_SEARCH_WEIGHTS&&(d+=` (score: ${s[o].score.toFixed(2)})`),l.parent&&(d=` - ${he(l.parent,i)}.${d}`);let m=document.createElement("li");m.classList.value=l.classes??"";let p=document.createElement("a");p.href=r.base+l.url,p.innerHTML=u+d,m.append(p),p.addEventListener("focus",()=>{e.querySelector(".current")?.classList.remove("current"),m.classList.add("current")}),e.appendChild(m)}}function de(t,e,n){let r=t.querySelector(".current");if(!r)r=t.querySelector(n==1?"li:first-child":"li:last-child"),r&&r.classList.add("current");else{let i=r;if(n===1)do i=i.nextElementSibling??void 0;while(i instanceof HTMLElement&&i.offsetParent==null);else do i=i.previousElementSibling??void 0;while(i instanceof HTMLElement&&i.offsetParent==null);i?(r.classList.remove("current"),i.classList.add("current")):n===-1&&(r.classList.remove("current"),e.focus())}}function He(t,e){let n=t.querySelector(".current");if(n||(n=t.querySelector("li:first-child")),n){let r=n.querySelector("a");r&&(window.location.href=r.href),te(e)}}function he(t,e){if(e==="")return t;let n=t.toLocaleLowerCase(),r=e.toLocaleLowerCase(),i=[],s=0,o=n.indexOf(r);for(;o!=-1;)i.push(ee(t.substring(s,o)),`${ee(t.substring(o,o+r.length))}`),s=o+r.length,o=n.indexOf(r,s);return i.push(ee(t.substring(s))),i.join("")}var Be={"&":"&","<":"<",">":">","'":"'",'"':"""};function ee(t){return t.replace(/[&<>"'"]/g,e=>Be[e])}var I=class{constructor(e){this.el=e.el,this.app=e.app}};var F="mousedown",ye="mousemove",H="mouseup",J={x:0,y:0},me=!1,ne=!1,je=!1,D=!1,ve=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);document.documentElement.classList.add(ve?"is-mobile":"not-mobile");ve&&"ontouchstart"in document.documentElement&&(je=!0,F="touchstart",ye="touchmove",H="touchend");document.addEventListener(F,t=>{ne=!0,D=!1;let e=F=="touchstart"?t.targetTouches[0]:t;J.y=e.pageY||0,J.x=e.pageX||0});document.addEventListener(ye,t=>{if(ne&&!D){let e=F=="touchstart"?t.targetTouches[0]:t,n=J.x-(e.pageX||0),r=J.y-(e.pageY||0);D=Math.sqrt(n*n+r*r)>10}});document.addEventListener(H,()=>{ne=!1});document.addEventListener("click",t=>{me&&(t.preventDefault(),t.stopImmediatePropagation(),me=!1)});var X=class extends I{constructor(e){super(e),this.className=this.el.dataset.toggle||"",this.el.addEventListener(H,n=>this.onPointerUp(n)),this.el.addEventListener("click",n=>n.preventDefault()),document.addEventListener(F,n=>this.onDocumentPointerDown(n)),document.addEventListener(H,n=>this.onDocumentPointerUp(n))}setActive(e){if(this.active==e)return;this.active=e,document.documentElement.classList.toggle("has-"+this.className,e),this.el.classList.toggle("active",e);let n=(this.active?"to-has-":"from-has-")+this.className;document.documentElement.classList.add(n),setTimeout(()=>document.documentElement.classList.remove(n),500)}onPointerUp(e){D||(this.setActive(!0),e.preventDefault())}onDocumentPointerDown(e){if(this.active){if(e.target.closest(".col-sidebar, .tsd-filter-group"))return;this.setActive(!1)}}onDocumentPointerUp(e){if(!D&&this.active&&e.target.closest(".col-sidebar")){let n=e.target.closest("a");if(n){let r=window.location.href;r.indexOf("#")!=-1&&(r=r.substring(0,r.indexOf("#"))),n.href.substring(0,r.length)==r&&setTimeout(()=>this.setActive(!1),250)}}}};var re;try{re=localStorage}catch{re={getItem(){return null},setItem(){}}}var Q=re;var ge=document.head.appendChild(document.createElement("style"));ge.dataset.for="filters";var Y=class extends I{constructor(e){super(e),this.key=`filter-${this.el.name}`,this.value=this.el.checked,this.el.addEventListener("change",()=>{this.setLocalStorage(this.el.checked)}),this.setLocalStorage(this.fromLocalStorage()),ge.innerHTML+=`html:not(.${this.key}) .tsd-is-${this.el.name} { display: none; } -`,this.app.updateIndexVisibility()}fromLocalStorage(){let e=Q.getItem(this.key);return e?e==="true":this.el.checked}setLocalStorage(e){Q.setItem(this.key,e.toString()),this.value=e,this.handleValueChange()}handleValueChange(){this.el.checked=this.value,document.documentElement.classList.toggle(this.key,this.value),this.app.filterChanged(),this.app.updateIndexVisibility()}};var Z=class extends I{constructor(e){super(e),this.summary=this.el.querySelector(".tsd-accordion-summary"),this.icon=this.summary.querySelector("svg"),this.key=`tsd-accordion-${this.summary.dataset.key??this.summary.textContent.trim().replace(/\s+/g,"-").toLowerCase()}`;let n=Q.getItem(this.key);this.el.open=n?n==="true":this.el.open,this.el.addEventListener("toggle",()=>this.update());let r=this.summary.querySelector("a");r&&r.addEventListener("click",()=>{location.assign(r.href)}),this.update()}update(){this.icon.style.transform=`rotate(${this.el.open?0:-90}deg)`,Q.setItem(this.key,this.el.open.toString())}};function Ee(t){let e=Q.getItem("tsd-theme")||"os";t.value=e,xe(e),t.addEventListener("change",()=>{Q.setItem("tsd-theme",t.value),xe(t.value)})}function xe(t){document.documentElement.dataset.theme=t}var K;function we(){let t=document.getElementById("tsd-nav-script");t&&(t.addEventListener("load",Le),Le())}async function Le(){let t=document.getElementById("tsd-nav-container");if(!t||!window.navigationData)return;let n=await(await fetch(window.navigationData)).arrayBuffer(),r=new Blob([n]).stream().pipeThrough(new DecompressionStream("gzip")),i=await new Response(r).json();K=t.dataset.base,K.endsWith("/")||(K+="/"),t.innerHTML="";for(let s of i)Se(s,t,[]);window.app.createComponents(t),window.app.showPage(),window.app.ensureActivePageVisible()}function Se(t,e,n){let r=e.appendChild(document.createElement("li"));if(t.children){let i=[...n,t.text],s=r.appendChild(document.createElement("details"));s.className=t.class?`${t.class} tsd-accordion`:"tsd-accordion";let o=s.appendChild(document.createElement("summary"));o.className="tsd-accordion-summary",o.dataset.key=i.join("$"),o.innerHTML='',be(t,o);let a=s.appendChild(document.createElement("div"));a.className="tsd-accordion-details";let l=a.appendChild(document.createElement("ul"));l.className="tsd-nested-navigation";for(let u of t.children)Se(u,l,i)}else be(t,r,t.class)}function be(t,e,n){if(t.path){let r=e.appendChild(document.createElement("a"));r.href=K+t.path,n&&(r.className=n),location.pathname===r.pathname&&r.classList.add("current"),t.kind&&(r.innerHTML=``),r.appendChild(document.createElement("span")).textContent=t.text}else e.appendChild(document.createElement("span")).textContent=t.text}G(X,"a[data-toggle]");G(Z,".tsd-accordion");G(Y,".tsd-filter-item input[type=checkbox]");var Te=document.getElementById("tsd-theme");Te&&Ee(Te);var qe=new U;Object.defineProperty(window,"app",{value:qe});fe();we();})(); +"use strict";(()=>{var Pe=Object.create;var ie=Object.defineProperty;var Oe=Object.getOwnPropertyDescriptor;var _e=Object.getOwnPropertyNames;var Re=Object.getPrototypeOf,Me=Object.prototype.hasOwnProperty;var Fe=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var De=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of _e(e))!Me.call(t,i)&&i!==n&&ie(t,i,{get:()=>e[i],enumerable:!(r=Oe(e,i))||r.enumerable});return t};var Ae=(t,e,n)=>(n=t!=null?Pe(Re(t)):{},De(e||!t||!t.__esModule?ie(n,"default",{value:t,enumerable:!0}):n,t));var ue=Fe((ae,le)=>{(function(){var t=function(e){var n=new t.Builder;return n.pipeline.add(t.trimmer,t.stopWordFilter,t.stemmer),n.searchPipeline.add(t.stemmer),e.call(n,n),n.build()};t.version="2.3.9";t.utils={},t.utils.warn=function(e){return function(n){e.console&&console.warn&&console.warn(n)}}(this),t.utils.asString=function(e){return e==null?"":e.toString()},t.utils.clone=function(e){if(e==null)return e;for(var n=Object.create(null),r=Object.keys(e),i=0;i0){var d=t.utils.clone(n)||{};d.position=[a,u],d.index=s.length,s.push(new t.Token(r.slice(a,o),d))}a=o+1}}return s},t.tokenizer.separator=/[\s\-]+/;t.Pipeline=function(){this._stack=[]},t.Pipeline.registeredFunctions=Object.create(null),t.Pipeline.registerFunction=function(e,n){n in this.registeredFunctions&&t.utils.warn("Overwriting existing registered function: "+n),e.label=n,t.Pipeline.registeredFunctions[e.label]=e},t.Pipeline.warnIfFunctionNotRegistered=function(e){var n=e.label&&e.label in this.registeredFunctions;n||t.utils.warn(`Function is not registered with pipeline. This may cause problems when serialising the index. +`,e)},t.Pipeline.load=function(e){var n=new t.Pipeline;return e.forEach(function(r){var i=t.Pipeline.registeredFunctions[r];if(i)n.add(i);else throw new Error("Cannot load unregistered function: "+r)}),n},t.Pipeline.prototype.add=function(){var e=Array.prototype.slice.call(arguments);e.forEach(function(n){t.Pipeline.warnIfFunctionNotRegistered(n),this._stack.push(n)},this)},t.Pipeline.prototype.after=function(e,n){t.Pipeline.warnIfFunctionNotRegistered(n);var r=this._stack.indexOf(e);if(r==-1)throw new Error("Cannot find existingFn");r=r+1,this._stack.splice(r,0,n)},t.Pipeline.prototype.before=function(e,n){t.Pipeline.warnIfFunctionNotRegistered(n);var r=this._stack.indexOf(e);if(r==-1)throw new Error("Cannot find existingFn");this._stack.splice(r,0,n)},t.Pipeline.prototype.remove=function(e){var n=this._stack.indexOf(e);n!=-1&&this._stack.splice(n,1)},t.Pipeline.prototype.run=function(e){for(var n=this._stack.length,r=0;r1&&(oe&&(r=s),o!=e);)i=r-n,s=n+Math.floor(i/2),o=this.elements[s*2];if(o==e||o>e)return s*2;if(ol?d+=2:a==l&&(n+=r[u+1]*i[d+1],u+=2,d+=2);return n},t.Vector.prototype.similarity=function(e){return this.dot(e)/this.magnitude()||0},t.Vector.prototype.toArray=function(){for(var e=new Array(this.elements.length/2),n=1,r=0;n0){var o=s.str.charAt(0),a;o in s.node.edges?a=s.node.edges[o]:(a=new t.TokenSet,s.node.edges[o]=a),s.str.length==1&&(a.final=!0),i.push({node:a,editsRemaining:s.editsRemaining,str:s.str.slice(1)})}if(s.editsRemaining!=0){if("*"in s.node.edges)var l=s.node.edges["*"];else{var l=new t.TokenSet;s.node.edges["*"]=l}if(s.str.length==0&&(l.final=!0),i.push({node:l,editsRemaining:s.editsRemaining-1,str:s.str}),s.str.length>1&&i.push({node:s.node,editsRemaining:s.editsRemaining-1,str:s.str.slice(1)}),s.str.length==1&&(s.node.final=!0),s.str.length>=1){if("*"in s.node.edges)var u=s.node.edges["*"];else{var u=new t.TokenSet;s.node.edges["*"]=u}s.str.length==1&&(u.final=!0),i.push({node:u,editsRemaining:s.editsRemaining-1,str:s.str.slice(1)})}if(s.str.length>1){var d=s.str.charAt(0),m=s.str.charAt(1),p;m in s.node.edges?p=s.node.edges[m]:(p=new t.TokenSet,s.node.edges[m]=p),s.str.length==1&&(p.final=!0),i.push({node:p,editsRemaining:s.editsRemaining-1,str:d+s.str.slice(2)})}}}return r},t.TokenSet.fromString=function(e){for(var n=new t.TokenSet,r=n,i=0,s=e.length;i=e;n--){var r=this.uncheckedNodes[n],i=r.child.toString();i in this.minimizedNodes?r.parent.edges[r.char]=this.minimizedNodes[i]:(r.child._str=i,this.minimizedNodes[i]=r.child),this.uncheckedNodes.pop()}};t.Index=function(e){this.invertedIndex=e.invertedIndex,this.fieldVectors=e.fieldVectors,this.tokenSet=e.tokenSet,this.fields=e.fields,this.pipeline=e.pipeline},t.Index.prototype.search=function(e){return this.query(function(n){var r=new t.QueryParser(e,n);r.parse()})},t.Index.prototype.query=function(e){for(var n=new t.Query(this.fields),r=Object.create(null),i=Object.create(null),s=Object.create(null),o=Object.create(null),a=Object.create(null),l=0;l1?this._b=1:this._b=e},t.Builder.prototype.k1=function(e){this._k1=e},t.Builder.prototype.add=function(e,n){var r=e[this._ref],i=Object.keys(this._fields);this._documents[r]=n||{},this.documentCount+=1;for(var s=0;s=this.length)return t.QueryLexer.EOS;var e=this.str.charAt(this.pos);return this.pos+=1,e},t.QueryLexer.prototype.width=function(){return this.pos-this.start},t.QueryLexer.prototype.ignore=function(){this.start==this.pos&&(this.pos+=1),this.start=this.pos},t.QueryLexer.prototype.backup=function(){this.pos-=1},t.QueryLexer.prototype.acceptDigitRun=function(){var e,n;do e=this.next(),n=e.charCodeAt(0);while(n>47&&n<58);e!=t.QueryLexer.EOS&&this.backup()},t.QueryLexer.prototype.more=function(){return this.pos1&&(e.backup(),e.emit(t.QueryLexer.TERM)),e.ignore(),e.more())return t.QueryLexer.lexText},t.QueryLexer.lexEditDistance=function(e){return e.ignore(),e.acceptDigitRun(),e.emit(t.QueryLexer.EDIT_DISTANCE),t.QueryLexer.lexText},t.QueryLexer.lexBoost=function(e){return e.ignore(),e.acceptDigitRun(),e.emit(t.QueryLexer.BOOST),t.QueryLexer.lexText},t.QueryLexer.lexEOS=function(e){e.width()>0&&e.emit(t.QueryLexer.TERM)},t.QueryLexer.termSeparator=t.tokenizer.separator,t.QueryLexer.lexText=function(e){for(;;){var n=e.next();if(n==t.QueryLexer.EOS)return t.QueryLexer.lexEOS;if(n.charCodeAt(0)==92){e.escapeCharacter();continue}if(n==":")return t.QueryLexer.lexField;if(n=="~")return e.backup(),e.width()>0&&e.emit(t.QueryLexer.TERM),t.QueryLexer.lexEditDistance;if(n=="^")return e.backup(),e.width()>0&&e.emit(t.QueryLexer.TERM),t.QueryLexer.lexBoost;if(n=="+"&&e.width()===1||n=="-"&&e.width()===1)return e.emit(t.QueryLexer.PRESENCE),t.QueryLexer.lexText;if(n.match(t.QueryLexer.termSeparator))return t.QueryLexer.lexTerm}},t.QueryParser=function(e,n){this.lexer=new t.QueryLexer(e),this.query=n,this.currentClause={},this.lexemeIdx=0},t.QueryParser.prototype.parse=function(){this.lexer.run(),this.lexemes=this.lexer.lexemes;for(var e=t.QueryParser.parseClause;e;)e=e(this);return this.query},t.QueryParser.prototype.peekLexeme=function(){return this.lexemes[this.lexemeIdx]},t.QueryParser.prototype.consumeLexeme=function(){var e=this.peekLexeme();return this.lexemeIdx+=1,e},t.QueryParser.prototype.nextClause=function(){var e=this.currentClause;this.query.clause(e),this.currentClause={}},t.QueryParser.parseClause=function(e){var n=e.peekLexeme();if(n!=null)switch(n.type){case t.QueryLexer.PRESENCE:return t.QueryParser.parsePresence;case t.QueryLexer.FIELD:return t.QueryParser.parseField;case t.QueryLexer.TERM:return t.QueryParser.parseTerm;default:var r="expected either a field or a term, found "+n.type;throw n.str.length>=1&&(r+=" with value '"+n.str+"'"),new t.QueryParseError(r,n.start,n.end)}},t.QueryParser.parsePresence=function(e){var n=e.consumeLexeme();if(n!=null){switch(n.str){case"-":e.currentClause.presence=t.Query.presence.PROHIBITED;break;case"+":e.currentClause.presence=t.Query.presence.REQUIRED;break;default:var r="unrecognised presence operator'"+n.str+"'";throw new t.QueryParseError(r,n.start,n.end)}var i=e.peekLexeme();if(i==null){var r="expecting term or field, found nothing";throw new t.QueryParseError(r,n.start,n.end)}switch(i.type){case t.QueryLexer.FIELD:return t.QueryParser.parseField;case t.QueryLexer.TERM:return t.QueryParser.parseTerm;default:var r="expecting term or field, found '"+i.type+"'";throw new t.QueryParseError(r,i.start,i.end)}}},t.QueryParser.parseField=function(e){var n=e.consumeLexeme();if(n!=null){if(e.query.allFields.indexOf(n.str)==-1){var r=e.query.allFields.map(function(o){return"'"+o+"'"}).join(", "),i="unrecognised field '"+n.str+"', possible fields: "+r;throw new t.QueryParseError(i,n.start,n.end)}e.currentClause.fields=[n.str];var s=e.peekLexeme();if(s==null){var i="expecting term, found nothing";throw new t.QueryParseError(i,n.start,n.end)}switch(s.type){case t.QueryLexer.TERM:return t.QueryParser.parseTerm;default:var i="expecting term, found '"+s.type+"'";throw new t.QueryParseError(i,s.start,s.end)}}},t.QueryParser.parseTerm=function(e){var n=e.consumeLexeme();if(n!=null){e.currentClause.term=n.str.toLowerCase(),n.str.indexOf("*")!=-1&&(e.currentClause.usePipeline=!1);var r=e.peekLexeme();if(r==null){e.nextClause();return}switch(r.type){case t.QueryLexer.TERM:return e.nextClause(),t.QueryParser.parseTerm;case t.QueryLexer.FIELD:return e.nextClause(),t.QueryParser.parseField;case t.QueryLexer.EDIT_DISTANCE:return t.QueryParser.parseEditDistance;case t.QueryLexer.BOOST:return t.QueryParser.parseBoost;case t.QueryLexer.PRESENCE:return e.nextClause(),t.QueryParser.parsePresence;default:var i="Unexpected lexeme type '"+r.type+"'";throw new t.QueryParseError(i,r.start,r.end)}}},t.QueryParser.parseEditDistance=function(e){var n=e.consumeLexeme();if(n!=null){var r=parseInt(n.str,10);if(isNaN(r)){var i="edit distance must be numeric";throw new t.QueryParseError(i,n.start,n.end)}e.currentClause.editDistance=r;var s=e.peekLexeme();if(s==null){e.nextClause();return}switch(s.type){case t.QueryLexer.TERM:return e.nextClause(),t.QueryParser.parseTerm;case t.QueryLexer.FIELD:return e.nextClause(),t.QueryParser.parseField;case t.QueryLexer.EDIT_DISTANCE:return t.QueryParser.parseEditDistance;case t.QueryLexer.BOOST:return t.QueryParser.parseBoost;case t.QueryLexer.PRESENCE:return e.nextClause(),t.QueryParser.parsePresence;default:var i="Unexpected lexeme type '"+s.type+"'";throw new t.QueryParseError(i,s.start,s.end)}}},t.QueryParser.parseBoost=function(e){var n=e.consumeLexeme();if(n!=null){var r=parseInt(n.str,10);if(isNaN(r)){var i="boost must be numeric";throw new t.QueryParseError(i,n.start,n.end)}e.currentClause.boost=r;var s=e.peekLexeme();if(s==null){e.nextClause();return}switch(s.type){case t.QueryLexer.TERM:return e.nextClause(),t.QueryParser.parseTerm;case t.QueryLexer.FIELD:return e.nextClause(),t.QueryParser.parseField;case t.QueryLexer.EDIT_DISTANCE:return t.QueryParser.parseEditDistance;case t.QueryLexer.BOOST:return t.QueryParser.parseBoost;case t.QueryLexer.PRESENCE:return e.nextClause(),t.QueryParser.parsePresence;default:var i="Unexpected lexeme type '"+s.type+"'";throw new t.QueryParseError(i,s.start,s.end)}}},function(e,n){typeof define=="function"&&define.amd?define(n):typeof ae=="object"?le.exports=n():e.lunr=n()}(this,function(){return t})})()});var se=[];function G(t,e){se.push({selector:e,constructor:t})}var U=class{constructor(){this.alwaysVisibleMember=null;this.createComponents(document.body),this.ensureFocusedElementVisible(),this.listenForCodeCopies(),window.addEventListener("hashchange",()=>this.ensureFocusedElementVisible()),document.body.style.display||(this.ensureFocusedElementVisible(),this.updateIndexVisibility(),this.scrollToHash())}createComponents(e){se.forEach(n=>{e.querySelectorAll(n.selector).forEach(r=>{r.dataset.hasInstance||(new n.constructor({el:r,app:this}),r.dataset.hasInstance=String(!0))})})}filterChanged(){this.ensureFocusedElementVisible()}showPage(){document.body.style.display&&(document.body.style.removeProperty("display"),this.ensureFocusedElementVisible(),this.updateIndexVisibility(),this.scrollToHash())}scrollToHash(){if(location.hash){let e=document.getElementById(location.hash.substring(1));if(!e)return;e.scrollIntoView({behavior:"instant",block:"start"})}}ensureActivePageVisible(){let e=document.querySelector(".tsd-navigation .current"),n=e?.parentElement;for(;n&&!n.classList.contains(".tsd-navigation");)n instanceof HTMLDetailsElement&&(n.open=!0),n=n.parentElement;if(e&&!Ve(e)){let r=e.getBoundingClientRect().top-document.documentElement.clientHeight/4;document.querySelector(".site-menu").scrollTop=r,document.querySelector(".col-sidebar").scrollTop=r}}updateIndexVisibility(){let e=document.querySelector(".tsd-index-content"),n=e?.open;e&&(e.open=!0),document.querySelectorAll(".tsd-index-section").forEach(r=>{r.style.display="block";let i=Array.from(r.querySelectorAll(".tsd-index-link")).every(s=>s.offsetParent==null);r.style.display=i?"none":"block"}),e&&(e.open=n)}ensureFocusedElementVisible(){if(this.alwaysVisibleMember&&(this.alwaysVisibleMember.classList.remove("always-visible"),this.alwaysVisibleMember.firstElementChild.remove(),this.alwaysVisibleMember=null),!location.hash)return;let e=document.getElementById(location.hash.substring(1));if(!e)return;let n=e.parentElement;for(;n&&n.tagName!=="SECTION";)n=n.parentElement;if(!n)return;let r=n.offsetParent==null,i=n;for(;i!==document.body;)i instanceof HTMLDetailsElement&&(i.open=!0),i=i.parentElement;if(n.offsetParent==null){this.alwaysVisibleMember=n,n.classList.add("always-visible");let s=document.createElement("p");s.classList.add("warning"),s.textContent=window.translations.normally_hidden,n.prepend(s)}r&&e.scrollIntoView()}listenForCodeCopies(){document.querySelectorAll("pre > button").forEach(e=>{let n;e.addEventListener("click",()=>{e.previousElementSibling instanceof HTMLElement&&navigator.clipboard.writeText(e.previousElementSibling.innerText.trim()),e.textContent=window.translations.copied,e.classList.add("visible"),clearTimeout(n),n=setTimeout(()=>{e.classList.remove("visible"),n=setTimeout(()=>{e.textContent=window.translations.copy},100)},1e3)})})}};function Ve(t){let e=t.getBoundingClientRect(),n=Math.max(document.documentElement.clientHeight,window.innerHeight);return!(e.bottom<0||e.top-n>=0)}var oe=(t,e=100)=>{let n;return()=>{clearTimeout(n),n=setTimeout(()=>t(),e)}};var pe=Ae(ue());async function ce(t,e){if(!window.searchData)return;let n=await fetch(window.searchData),r=new Blob([await n.arrayBuffer()]).stream().pipeThrough(new DecompressionStream("gzip")),i=await new Response(r).json();t.data=i,t.index=pe.Index.load(i.index),e.classList.remove("loading"),e.classList.add("ready")}function fe(){let t=document.getElementById("tsd-search");if(!t)return;let e={base:t.dataset.base+"/"},n=document.getElementById("tsd-search-script");t.classList.add("loading"),n&&(n.addEventListener("error",()=>{t.classList.remove("loading"),t.classList.add("failure")}),n.addEventListener("load",()=>{ce(e,t)}),ce(e,t));let r=document.querySelector("#tsd-search input"),i=document.querySelector("#tsd-search .results");if(!r||!i)throw new Error("The input field or the result list wrapper was not found");i.addEventListener("mouseup",()=>{te(t)}),r.addEventListener("focus",()=>t.classList.add("has-focus")),He(t,i,r,e)}function He(t,e,n,r){n.addEventListener("input",oe(()=>{Ne(t,e,n,r)},200)),n.addEventListener("keydown",i=>{i.key=="Enter"?Be(e,t):i.key=="ArrowUp"?(de(e,n,-1),i.preventDefault()):i.key==="ArrowDown"&&(de(e,n,1),i.preventDefault())}),document.body.addEventListener("keypress",i=>{i.altKey||i.ctrlKey||i.metaKey||!n.matches(":focus")&&i.key==="/"&&(i.preventDefault(),n.focus())}),document.body.addEventListener("keyup",i=>{t.classList.contains("has-focus")&&(i.key==="Escape"||!e.matches(":focus-within")&&!n.matches(":focus"))&&(n.blur(),te(t))})}function te(t){t.classList.remove("has-focus")}function Ne(t,e,n,r){if(!r.index||!r.data)return;e.textContent="";let i=n.value.trim(),s;if(i){let o=i.split(" ").map(a=>a.length?`*${a}*`:"").join(" ");s=r.index.search(o)}else s=[];for(let o=0;oa.score-o.score);for(let o=0,a=Math.min(10,s.length);o`,d=he(l.name,i);globalThis.DEBUG_SEARCH_WEIGHTS&&(d+=` (score: ${s[o].score.toFixed(2)})`),l.parent&&(d=` + ${he(l.parent,i)}.${d}`);let m=document.createElement("li");m.classList.value=l.classes??"";let p=document.createElement("a");p.href=r.base+l.url,p.innerHTML=u+d,m.append(p),p.addEventListener("focus",()=>{e.querySelector(".current")?.classList.remove("current"),m.classList.add("current")}),e.appendChild(m)}}function de(t,e,n){let r=t.querySelector(".current");if(!r)r=t.querySelector(n==1?"li:first-child":"li:last-child"),r&&r.classList.add("current");else{let i=r;if(n===1)do i=i.nextElementSibling??void 0;while(i instanceof HTMLElement&&i.offsetParent==null);else do i=i.previousElementSibling??void 0;while(i instanceof HTMLElement&&i.offsetParent==null);i?(r.classList.remove("current"),i.classList.add("current")):n===-1&&(r.classList.remove("current"),e.focus())}}function Be(t,e){let n=t.querySelector(".current");if(n||(n=t.querySelector("li:first-child")),n){let r=n.querySelector("a");r&&(window.location.href=r.href),te(e)}}function he(t,e){if(e==="")return t;let n=t.toLocaleLowerCase(),r=e.toLocaleLowerCase(),i=[],s=0,o=n.indexOf(r);for(;o!=-1;)i.push(ee(t.substring(s,o)),`${ee(t.substring(o,o+r.length))}`),s=o+r.length,o=n.indexOf(r,s);return i.push(ee(t.substring(s))),i.join("")}var je={"&":"&","<":"<",">":">","'":"'",'"':"""};function ee(t){return t.replace(/[&<>"'"]/g,e=>je[e])}var I=class{constructor(e){this.el=e.el,this.app=e.app}};var F="mousedown",ye="mousemove",N="mouseup",J={x:0,y:0},me=!1,ne=!1,qe=!1,D=!1,ve=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);document.documentElement.classList.add(ve?"is-mobile":"not-mobile");ve&&"ontouchstart"in document.documentElement&&(qe=!0,F="touchstart",ye="touchmove",N="touchend");document.addEventListener(F,t=>{ne=!0,D=!1;let e=F=="touchstart"?t.targetTouches[0]:t;J.y=e.pageY||0,J.x=e.pageX||0});document.addEventListener(ye,t=>{if(ne&&!D){let e=F=="touchstart"?t.targetTouches[0]:t,n=J.x-(e.pageX||0),r=J.y-(e.pageY||0);D=Math.sqrt(n*n+r*r)>10}});document.addEventListener(N,()=>{ne=!1});document.addEventListener("click",t=>{me&&(t.preventDefault(),t.stopImmediatePropagation(),me=!1)});var X=class extends I{constructor(e){super(e),this.className=this.el.dataset.toggle||"",this.el.addEventListener(N,n=>this.onPointerUp(n)),this.el.addEventListener("click",n=>n.preventDefault()),document.addEventListener(F,n=>this.onDocumentPointerDown(n)),document.addEventListener(N,n=>this.onDocumentPointerUp(n))}setActive(e){if(this.active==e)return;this.active=e,document.documentElement.classList.toggle("has-"+this.className,e),this.el.classList.toggle("active",e);let n=(this.active?"to-has-":"from-has-")+this.className;document.documentElement.classList.add(n),setTimeout(()=>document.documentElement.classList.remove(n),500)}onPointerUp(e){D||(this.setActive(!0),e.preventDefault())}onDocumentPointerDown(e){if(this.active){if(e.target.closest(".col-sidebar, .tsd-filter-group"))return;this.setActive(!1)}}onDocumentPointerUp(e){if(!D&&this.active&&e.target.closest(".col-sidebar")){let n=e.target.closest("a");if(n){let r=window.location.href;r.indexOf("#")!=-1&&(r=r.substring(0,r.indexOf("#"))),n.href.substring(0,r.length)==r&&setTimeout(()=>this.setActive(!1),250)}}}};var re;try{re=localStorage}catch{re={getItem(){return null},setItem(){}}}var Q=re;var ge=document.head.appendChild(document.createElement("style"));ge.dataset.for="filters";var Y=class extends I{constructor(e){super(e),this.key=`filter-${this.el.name}`,this.value=this.el.checked,this.el.addEventListener("change",()=>{this.setLocalStorage(this.el.checked)}),this.setLocalStorage(this.fromLocalStorage()),ge.innerHTML+=`html:not(.${this.key}) .tsd-is-${this.el.name} { display: none; } +`,this.app.updateIndexVisibility()}fromLocalStorage(){let e=Q.getItem(this.key);return e?e==="true":this.el.checked}setLocalStorage(e){Q.setItem(this.key,e.toString()),this.value=e,this.handleValueChange()}handleValueChange(){this.el.checked=this.value,document.documentElement.classList.toggle(this.key,this.value),this.app.filterChanged(),this.app.updateIndexVisibility()}};var Z=class extends I{constructor(e){super(e),this.summary=this.el.querySelector(".tsd-accordion-summary"),this.icon=this.summary.querySelector("svg"),this.key=`tsd-accordion-${this.summary.dataset.key??this.summary.textContent.trim().replace(/\s+/g,"-").toLowerCase()}`;let n=Q.getItem(this.key);this.el.open=n?n==="true":this.el.open,this.el.addEventListener("toggle",()=>this.update());let r=this.summary.querySelector("a");r&&r.addEventListener("click",()=>{location.assign(r.href)}),this.update()}update(){this.icon.style.transform=`rotate(${this.el.open?0:-90}deg)`,Q.setItem(this.key,this.el.open.toString())}};function Ee(t){let e=Q.getItem("tsd-theme")||"os";t.value=e,xe(e),t.addEventListener("change",()=>{Q.setItem("tsd-theme",t.value),xe(t.value)})}function xe(t){document.documentElement.dataset.theme=t}var K;function we(){let t=document.getElementById("tsd-nav-script");t&&(t.addEventListener("load",Le),Le())}async function Le(){let t=document.getElementById("tsd-nav-container");if(!t||!window.navigationData)return;let n=await(await fetch(window.navigationData)).arrayBuffer(),r=new Blob([n]).stream().pipeThrough(new DecompressionStream("gzip")),i=await new Response(r).json();K=t.dataset.base,K.endsWith("/")||(K+="/"),t.innerHTML="";for(let s of i)Se(s,t,[]);window.app.createComponents(t),window.app.showPage(),window.app.ensureActivePageVisible()}function Se(t,e,n){let r=e.appendChild(document.createElement("li"));if(t.children){let i=[...n,t.text],s=r.appendChild(document.createElement("details"));s.className=t.class?`${t.class} tsd-accordion`:"tsd-accordion";let o=s.appendChild(document.createElement("summary"));o.className="tsd-accordion-summary",o.dataset.key=i.join("$"),o.innerHTML='',be(t,o);let a=s.appendChild(document.createElement("div"));a.className="tsd-accordion-details";let l=a.appendChild(document.createElement("ul"));l.className="tsd-nested-navigation";for(let u of t.children)Se(u,l,i)}else be(t,r,t.class)}function be(t,e,n){if(t.path){let r=e.appendChild(document.createElement("a"));r.href=K+t.path,n&&(r.className=n),location.pathname===r.pathname&&r.classList.add("current"),t.kind&&(r.innerHTML=``),r.appendChild(document.createElement("span")).textContent=t.text}else e.appendChild(document.createElement("span")).textContent=t.text}G(X,"a[data-toggle]");G(Z,".tsd-accordion");G(Y,".tsd-filter-item input[type=checkbox]");var Te=document.getElementById("tsd-theme");Te&&Ee(Te);var $e=new U;Object.defineProperty(window,"app",{value:$e});fe();we();})(); /*! Bundled license information: lunr/lunr.js: diff --git a/assets/navigation.js b/assets/navigation.js index 9f621fdf..02116423 100644 --- a/assets/navigation.js +++ b/assets/navigation.js @@ -1 +1 @@ -window.navigationData = "data:application/octet-stream;base64,H4sIAAAAAAAAA62YW0/bMBSA/0v2ygbtCht9YzBNTAzQuu0FIctN3NbgXOYLAk38dxLHqR1iu2bxG/I5/vzh1CcnvvmXcPTIk3mSQQ6XkKFkL6kg39QjeZkJgth+F/mw4Tmpw/e4yJL5dC9JN5hkFBXJ/EZj0AoKwjUlJZAxk6Iy+rTJ9PPz7fOexpSpyFHBLTYqMtKmowTZIEpLOlSRw+M8WoRTQitUZSUI5LgsHB5AZ0RQMmlBW/QACc68fjojhp9B8/iZhgQv9+9YWTBOEcyHlnUc6HiQYwWpeWBWokgbowFL5vWJR7OeXC2ByNBJDo/brhYR9AxzUf9hkWiGR0pIRJDEX4Ho01BCDo+TaBFBEizdoBwOLdrxcRqK8QYP/lRZyrKOxfCRnCCnJpMNdeRwkMkJpdDyhDXgXZfRYmaT49nHg5mh8KUsCYKWSmMwdI6TIlYrZCnrJqRLcTFOf5+feQkqwTX/DHLLozXmqwTX/K+FsJQyY75KcM0/Lzha79gEneOi/MCPKPMyugwX4VLkyx0a2xQX42p5h1JLx2AwtikuxoJTXKy9jG2Ki/EHUy6gpZobEJ3jokDPKQEyOO7Ym6Cgc7/0HjqgwjGkOlSYlu8UgzYaRaolBTmlAruOA2hiMXwkJ6yXdtcY0MRi2EhOWC/trligicWwkZwgG+ytf0CFYzh1qCCtwlcOQRuNIaVIQU6lr7yCNhrDSZHC+iNfuQZtNIaTIoV9CXnLP1DhGFYdKvADyNe4vZ+EtW5ZtpDt4q960kVZVleV/ODR1OZnTlcwNcCuSa9WPDwy3+UB3ABMb2nZgwzAkmZ3NSe8WuXg+NPkcOpa6S2L/A9/gfOKvGmV3oxda13Wn4zfFxf4Hp1CQpYwvXetMczcxb5u7xXQT8R6v+w+t5+1ixm88YG7bh4awbHlKDejQQem7q+mdUGz3RFIhooP7gaMtzci17SsnAQV9xDWiHsJKu4hyPuLE7pmTsY2w0Oh6AE57kskQ8U9BIb4N8S5+WZ8xdhm+Cne/WA794Nt6maQuP8TFbfc+Ny+AJmudaBxFQAA" \ No newline at end of file +window.navigationData = "data:application/octet-stream;base64,H4sIAAAAAAAAA62XXW+bMBSG/wvX2bpEa7flrurFpKnbqmV3VRUZOEncGMz8UbWa+t8HtlMg2ORk+C7ye3j84AA+vv+bKHhWyTLJiSIpkZDMkoqoXT1S8FwzkBeH5P1OFayO97TMk+VilmQ7ynIBZbK8bzGwIZqplpIxImWX4ir6tPni8+vD66zF8EwXUCqPjUsm2hwoKBsQgouhihme5mERQYlWoeKVZkRRXgY81m1FBKUuDbVET4TRfNSvrYjh16GN+HUNGU0vHiUvpRJAiqFlna/bHOVYEdF9YTa6zBqjAcvU9YlXH3tytQSwoZMZnrZcFoH6Dwtd//BINMMTJQwCJfFHg3gZSpjhaRIWgZKQ2Q4KMrSw49M0HOMMD/VSeT7LbRbDx3BQTk2lHOqYYZQJEYJ4/mEDWJtw2g11Qag7SjlnQDwfLktycQypAwqnpTcb8Gw7DmXSKFKWhHLKNM1DRk0Ww8dwcF0CUZ4Xw1KaLIaN4eC6hFJ7thVLabIYNoaDsqGlgm348XFxDKcDCqVV+6dhK5vGkHIklBNPHyHztJqWZNMYTo6E+/IrQcttyMmmMZwcCdfjUaE08bQpFuXiGFYHFLK1G9uS3s1RQtd5vjIb4e/6olvOq5+VaeVaavOYiw3JOuDQRUczXl51XDFcBKY39Xf6DPkAbGh+1+4FR7N8+PJpfrkIzXTOJP/DX9GiYmfN0rvi1Fw/6mb42+qW7uGGMJaSbB+aY1h5in1nT0zwC2Tvye5z+1WnmOiFR65696XRinpe5WYU28Ut6g+a7/RjGC4fnHo6uzewO8GrIMHlI4QtqFGCy0cI5mR2LbYyyHirGKEIeILASdAwXD5CkKC+glLdnfGI8VYxThldD3lyPeSubgZZ+E5c7jnLPvwDUts4zksSAAA=" \ No newline at end of file diff --git a/assets/style.css b/assets/style.css index d0c980d4..9d619a64 100644 --- a/assets/style.css +++ b/assets/style.css @@ -793,6 +793,15 @@ input[type="checkbox"]:checked ~ svg .tsd-checkbox-checkmark { margin-left: -1.5rem; } +.tsd-page-navigation-section { + margin-left: 10px; +} +.tsd-page-navigation-section > summary { + padding: 0.25rem; +} +.tsd-page-navigation-section > div { + margin-left: 20px; +} .tsd-page-navigation ul { padding-left: 1.75rem; } @@ -841,6 +850,7 @@ a.tsd-index-link { } .tsd-accordion .tsd-accordion-summary > svg { margin-left: 0.25rem; + vertical-align: text-top; } .tsd-index-content > :not(:first-child) { margin-top: 0.75rem; diff --git a/classes/database.default.html b/classes/database.default.html index f63a8ac3..3f78584c 100644 --- a/classes/database.default.html +++ b/classes/database.default.html @@ -1,4 +1,4 @@ -default | hexojs/warehouse

Constructors

constructor +default | hexojs/warehouse

Constructors

Properties

Model Schema SchemaType @@ -12,7 +12,7 @@ save toJSON

Constructors

  • Database constructor.

    -

    Parameters

    • Optionaloptions: {
          path: string;
      } & Partial<DatabaseOptions>

    Returns default

Properties

Model: typeof default
Schema: typeof default
SchemaType: typeof default
_models: Record<string, default<any>>
options: DatabaseOptions
Schema: typeof default = Schema
SchemaType: typeof default = SchemaType
version: number

Methods

  • Returns {
        meta: {
            version: number;
            warehouse: string;
        };
        models: Record<string, default<any>>;
    }

    • meta: {
          version: number;
          warehouse: string;
      }
      • version: number
      • warehouse: string
    • models: Record<string, default<any>>
\ No newline at end of file +

Parameters

  • Optionaloptions: {
        path: string;
    } & Partial<DatabaseOptions>

Returns default

Properties

Model: typeof default
Schema: typeof default
SchemaType: typeof default
_models: Record<string, default<any>>
options: DatabaseOptions
Schema: typeof default = Schema
SchemaType: typeof default = SchemaType
version: number

Methods

  • Returns {
        meta: {
            version: number;
            warehouse: string;
        };
        models: Record<string, default<any>>;
    }

    • meta: {
          version: number;
          warehouse: string;
      }
      • version: number
      • warehouse: string
    • models: Record<string, default<any>>
diff --git a/classes/document.default.html b/classes/document.default.html index f57cdc88..90ab6cd1 100644 --- a/classes/document.default.html +++ b/classes/document.default.html @@ -1,4 +1,4 @@ -default | hexojs/warehouse

Class default<T>Abstract

Type Parameters

  • T

Indexable

  • [key: string]: any

Constructors

constructor +default | hexojs/warehouse

Class default<T>Abstract

Type Parameters

  • T

Indexable

  • [key: string]: any

Constructors

Properties

_id _model _schema @@ -10,11 +10,11 @@ toString update

Constructors

Properties

_id: string | number
_model: default<T>
_schema: default<T>

Methods

  • Populates document references.

    -

    Parameters

    • expr: string | any[] | {
          model?: any;
          path?: string;
          [key: PropertyKey]: any;
      }

    Returns default<T>

  • Returns a plain JavaScript object.

    -

    Returns T

  • Returns a string representing the document.

    -

    Returns string

  • Updates the document.

    -

    Parameters

    Returns Bluebird<any>

\ No newline at end of file +

Type Parameters

  • T

Parameters

  • Optionaldata: T

Returns default<T>

Properties

_id: string | number
_model: default<T>
_schema: default<T>

Methods

  • Populates document references.

    +

    Parameters

    • expr: string | any[] | {
          model?: any;
          path?: string;
          [key: PropertyKey]: any;
      }

    Returns default<T>

  • Returns a plain JavaScript object.

    +

    Returns T

  • Returns a string representing the document.

    +

    Returns string

  • Updates the document.

    +

    Parameters

    Returns Bluebird<any>

diff --git a/classes/error.default.html b/classes/error.default.html index df6cd3ed..86587e1c 100644 --- a/classes/error.default.html +++ b/classes/error.default.html @@ -1,7 +1,7 @@ -default | hexojs/warehouse

Hierarchy (view full)

Constructors

constructor +default | hexojs/warehouse

Hierarchy (view full)

Constructors

  • WarehouseError constructor

    -

    Parameters

    • msg: string
    • Optionalcode: string

    Returns default

Properties

code?: string
ID_EXIST: string = 'ID_EXIST'
ID_NOT_EXIST: string = 'ID_NOT_EXIST'
ID_UNDEFINED: string = 'ID_UNDEFINED'
\ No newline at end of file +

Parameters

  • msg: string
  • Optionalcode: string

Returns default

Properties

code?: string
ID_EXIST: string = 'ID_EXIST'
ID_NOT_EXIST: string = 'ID_NOT_EXIST'
ID_UNDEFINED: string = 'ID_UNDEFINED'
diff --git a/classes/error_population.default.html b/classes/error_population.default.html index b8693ac6..af981b7d 100644 --- a/classes/error_population.default.html +++ b/classes/error_population.default.html @@ -1,7 +1,7 @@ -default | hexojs/warehouse

Hierarchy (view full)

Constructors

constructor +default | hexojs/warehouse

Hierarchy (view full)

Constructors

Properties

code?: string
ID_EXIST: string = 'ID_EXIST'
ID_NOT_EXIST: string = 'ID_NOT_EXIST'
ID_UNDEFINED: string = 'ID_UNDEFINED'
\ No newline at end of file +

Parameters

  • msg: string
  • Optionalcode: string

Returns default

Properties

code?: string
ID_EXIST: string = 'ID_EXIST'
ID_NOT_EXIST: string = 'ID_NOT_EXIST'
ID_UNDEFINED: string = 'ID_UNDEFINED'
diff --git a/classes/error_validation.default.html b/classes/error_validation.default.html index 8683c270..af750f6a 100644 --- a/classes/error_validation.default.html +++ b/classes/error_validation.default.html @@ -1,7 +1,7 @@ -default | hexojs/warehouse

Hierarchy (view full)

Constructors

constructor +default | hexojs/warehouse

Hierarchy (view full)

Constructors

Properties

code?: string
ID_EXIST: string = 'ID_EXIST'
ID_NOT_EXIST: string = 'ID_NOT_EXIST'
ID_UNDEFINED: string = 'ID_UNDEFINED'
\ No newline at end of file +

Parameters

  • msg: string
  • Optionalcode: string

Returns default

Properties

code?: string
ID_EXIST: string = 'ID_EXIST'
ID_NOT_EXIST: string = 'ID_NOT_EXIST'
ID_UNDEFINED: string = 'ID_UNDEFINED'
diff --git a/classes/model.default.html b/classes/model.default.html index d709a5f9..5144e9b9 100644 --- a/classes/model.default.html +++ b/classes/model.default.html @@ -1,4 +1,4 @@ -default | hexojs/warehouse

Type Parameters

  • T

Hierarchy

  • EventEmitter
    • default

Constructors

constructor +default | hexojs/warehouse

Type Parameters

  • T

Hierarchy

  • EventEmitter
    • default

Constructors

Properties

Document Query _database @@ -49,57 +49,57 @@

Constructors

Properties

Document: any
Query: any
_database: default
_mutex: default = ...
data: Record<PropertyKey, T> = {}
each: ((iterator: ((value: any, index: number) => void), options?: Options) => void)

Type declaration

    • (iterator, options?): void
    • Iterates over all documents.

      +

Returns default<T>

Properties

Document: any
Query: any
_database: default
_mutex: default = ...
data: Record<PropertyKey, T> = {}
each: ((iterator: ((value: any, index: number) => void), options?: Options) => void)

Type declaration

    • (iterator, options?): void
    • Iterates over all documents.

      Parameters

      • iterator: ((value: any, index: number) => void)
          • (value, index): void
          • Parameters

            • value: any
            • index: number

            Returns void

      • Optionaloptions: Options

        See Model#findById.

        -

      Returns void

get: ((id: PropertyKey, options_?: Options) => T | default<T>)

Type declaration

    • (id, options_?): T | default<T>
    • Finds a document by its identifier.

      -

      Parameters

      • id: PropertyKey
      • Optionaloptions_: Options

      Returns T | default<T>

length: number = 0
name: string

Model name

-
random: (() => default<T>)

Type declaration

schema: default<T>
size: (() => number)

Type declaration

    • (): number
    • Returns the number of elements.

      -

      Returns number

Methods

  • Returns the number of elements.

    -

    Returns number

  • Deletes a model.

    -

    Returns void

  • Returns the document at the specified index. num can be a positive or +

Returns void

get: ((id: PropertyKey, options_?: Options) => T | default<T>)

Type declaration

    • (id, options_?): T | default<T>
    • Finds a document by its identifier.

      +

      Parameters

      • id: PropertyKey
      • Optionaloptions_: Options

      Returns T | default<T>

length: number = 0
name: string

Model name

+
random: (() => default<T>)

Type declaration

schema: default<T>
size: (() => number)

Type declaration

    • (): number
    • Returns the number of elements.

      +

      Returns number

Methods

  • Returns the number of elements.

    +

    Returns number

  • Deletes a model.

    +

    Returns void

  • Returns the document at the specified index. num can be a positive or negative number.

    Parameters

    • i_: number
    • Optionaloptions: Options

      See Model#findById.

      -

    Returns default<T> | Record<PropertyKey, any>

  • Tests whether all documents pass the test implemented by the provided +

Returns default<T> | Record<PropertyKey, any>

  • Tests whether all documents pass the test implemented by the provided function.

    -

    Parameters

    • iterator: ((value: any, index: number) => any)
        • (value, index): any
        • Parameters

          • value: any
          • index: number

          Returns any

    Returns boolean

  • Creates a new array with all documents that pass the test implemented by the +

    Parameters

    • iterator: ((value: any, index: number) => any)
        • (value, index): any
        • Parameters

          • value: any
          • index: number

          Returns any

    Returns boolean

  • Creates a new array with all documents that pass the test implemented by the provided function.

    -

    Parameters

    • iterator: ((value: any, index: number) => any)
        • (value, index): any
        • Parameters

          • value: any
          • index: number

          Returns any

    • Optionaloptions: Options

    Returns default<T>

  • Returns the first document.

    +

    Parameters

    • iterator: ((value: any, index: number) => any)
        • (value, index): any
        • Parameters

          • value: any
          • index: number

          Returns any

    • Optionaloptions: Options

    Returns default<T>

  • Returns the first document.

    Parameters

    • Optionaloptions: Options

      See Model#findById.

      -

    Returns default<T> | Record<PropertyKey, any>

  • Iterates over all documents.

    +

Returns default<T> | Record<PropertyKey, any>

  • Iterates over all documents.

    Parameters

    • iterator: ((value: any, index: number) => void)
        • (value, index): void
        • Parameters

          • value: any
          • index: number

          Returns void

    • Optionaloptions: Options

      See Model#findById.

      -

    Returns void

  • Checks if the model contains a document with the specified id.

    -

    Parameters

    • id: PropertyKey

    Returns boolean

  • Returns the last document.

    +

Returns void

  • Checks if the model contains a document with the specified id.

    +

    Parameters

    • id: PropertyKey

    Returns boolean

  • Returns the last document.

    Parameters

    • Optionaloptions: Options

      See Model#findById.

      -

    Returns default<T> | Record<PropertyKey, any>

  • Creates an array of values by iterating each element in the collection.

    -

    Type Parameters

    • T

    Parameters

    • iterator: ((value: any, index: number) => T)
        • (value, index): T
        • Parameters

          • value: any
          • index: number

          Returns T

    • Optionaloptions: Options

    Returns T[]

  • Populates document references.

    -

    Parameters

    • path: string | any[] | {
          model?: any;
          path?: string;
          [key: PropertyKey]: any;
      }

    Returns default<T>

  • Reduces a collection to a value which is the accumulated result of iterating +

Returns default<T> | Record<PropertyKey, any>

  • Creates an array of values by iterating each element in the collection.

    +

    Type Parameters

    • T

    Parameters

    • iterator: ((value: any, index: number) => T)
        • (value, index): T
        • Parameters

          • value: any
          • index: number

          Returns T

    • Optionaloptions: Options

    Returns T[]

  • Populates document references.

    +

    Parameters

    • path: string | any[] | {
          model?: any;
          path?: string;
          [key: PropertyKey]: any;
      }

    Returns default<T>

  • Reduces a collection to a value which is the accumulated result of iterating each element in the collection.

    Type Parameters

    • T

    Parameters

    • iterator: ((pre: any, cur: any, index: number) => T)
        • (pre, cur, index): T
        • Parameters

          • pre: any
          • cur: any
          • index: number

          Returns T

    • Optionalinitial: T

      By default, the initial value is the first document.

      -

    Returns T

  • Reduces a collection to a value which is the accumulated result of iterating +

Returns T

  • Reduces a collection to a value which is the accumulated result of iterating each element in the collection from right to left.

    Type Parameters

    • T

    Parameters

    • iterator: ((pre: any, cur: any, index: number) => T)
        • (pre, cur, index): T
        • Parameters

          • pre: any
          • cur: any
          • index: number

          Returns T

    • Optionalinitial: T

      By default, the initial value is the last document.

      -

    Returns T

  • Removes matching documents.

    -

    Parameters

    Returns Bluebird<any>

  • Finds a document by its identifier and remove it.

    -

    Parameters

    Returns Bluebird<any>

  • Replaces matching documents.

    -

    Parameters

    Returns Bluebird<any>

  • Finds a document by its identifier and replace it.

    -

    Parameters

    Returns Bluebird<any>

  • Inserts the document if it does not exist; otherwise updates it.

    -

    Parameters

    Returns Bluebird<any>

  • Returns the specified range of documents.

    -

    Parameters

    • Optionalstart_: number
    • Optionalend_: number

    Returns default<T>

  • Tests whether some documents pass the test implemented by the provided +

Returns T

  • Removes matching documents.

    +

    Parameters

    Returns Bluebird<any>

  • Finds a document by its identifier and remove it.

    +

    Parameters

    Returns Bluebird<any>

  • Replaces matching documents.

    +

    Parameters

    Returns Bluebird<any>

  • Finds a document by its identifier and replace it.

    +

    Parameters

    Returns Bluebird<any>

  • Inserts the document if it does not exist; otherwise updates it.

    +

    Parameters

    Returns Bluebird<any>

  • Returns the specified range of documents.

    +

    Parameters

    • Optionalstart_: number
    • Optionalend_: number

    Returns default<T>

  • Tests whether some documents pass the test implemented by the provided function.

    -

    Parameters

    • iterator: ((value: any, index: number) => any)
        • (value, index): any
        • Parameters

          • value: any
          • index: number

          Returns any

    Returns boolean

  • Returns an array containing all documents.

    +

    Parameters

    • iterator: ((value: any, index: number) => any)
        • (value, index): any
        • Parameters

          • value: any
          • index: number

          Returns any

    Returns boolean

  • Returns an array containing all documents.

    Parameters

    • Optionaloptions: Options

      See Model#findById.

      -

    Returns any[]

  • Updates matching documents.

    -

    Parameters

    Returns Bluebird<any>

  • Finds a document by its identifier and update it.

    -

    Parameters

    Returns Bluebird<any>

\ No newline at end of file +

Returns any[]

  • Updates matching documents.

    +

    Parameters

    Returns Bluebird<any>

  • Finds a document by its identifier and update it.

    +

    Parameters

    Returns Bluebird<any>

diff --git a/classes/mutex.default.html b/classes/mutex.default.html index a0525519..6fd646df 100644 --- a/classes/mutex.default.html +++ b/classes/mutex.default.html @@ -1,4 +1,4 @@ -default | hexojs/warehouse

Constructors

constructor +default | hexojs/warehouse

Constructors

Methods

Constructors

Methods

  • Parameters

    • fn: (() => void)
        • (): void
        • Returns void

    Returns void

\ No newline at end of file +

Constructors

Methods

  • Parameters

    • fn: (() => void)
        • (): void
        • Returns void

    Returns void

diff --git a/classes/query.default.html b/classes/query.default.html index a8ce4312..cd1cd430 100644 --- a/classes/query.default.html +++ b/classes/query.default.html @@ -1,4 +1,4 @@ -default | hexojs/warehouse

Class default<T>Abstract

Type Parameters

  • T

Constructors

constructor +default | hexojs/warehouse

Class default<T>Abstract

Type Parameters

  • T

Constructors

Properties

_model _schema data @@ -31,47 +31,47 @@ toArray update

Constructors

Properties

_model: default<T>
_schema: default<T>
data: default<T>[]
each: ((iterator: ((item: any, index: number) => void)) => void)

Type declaration

    • (iterator): void
    • Iterates over all documents.

      -

      Parameters

      • iterator: ((item: any, index: number) => void)
          • (item, index): void
          • Parameters

            • item: any
            • index: number

            Returns void

      Returns void

length: number
random: (() => default<T>)

Type declaration

size: (() => number)

Type declaration

Properties

_model: default<T>
_schema: default<T>
data: default<T>[]
each: ((iterator: ((item: any, index: number) => void)) => void)

Type declaration

    • (iterator): void
    • Iterates over all documents.

      +

      Parameters

      • iterator: ((item: any, index: number) => void)
          • (item, index): void
          • Parameters

            • item: any
            • index: number

            Returns void

      Returns void

length: number
random: (() => default<T>)

Type declaration

size: (() => number)

Type declaration

    • (): number
    • Returns the number of elements.

      Returns number

      Number

      -

Methods

  • Returns the number of elements.

    +

Methods

  • Returns the number of elements.

    Returns number

    Number

    -
  • Returns the document at the specified index. num can be a positive or +

  • Returns the document at the specified index. num can be a positive or negative number.

    -

    Parameters

    • i: number

    Returns default<T>

  • Tests whether all documents pass the test implemented by the provided +

    Parameters

    • i: number

    Returns default<T>

  • Tests whether all documents pass the test implemented by the provided function.

    -

    Parameters

    • iterator: ((item: any, index: number) => boolean)
        • (item, index): boolean
        • Parameters

          • item: any
          • index: number

          Returns boolean

    Returns boolean

  • Creates a new array with all documents that pass the test implemented by the +

    Parameters

    • iterator: ((item: any, index: number) => boolean)
        • (item, index): boolean
        • Parameters

          • item: any
          • index: number

          Returns boolean

    Returns boolean

  • Creates a new array with all documents that pass the test implemented by the provided function.

    -

    Parameters

    • iterator: ((item: any, index: number) => boolean)
        • (item, index): boolean
        • Parameters

          • item: any
          • index: number

          Returns boolean

    Returns default<T>

  • Iterates over all documents.

    -

    Parameters

    • iterator: ((item: any, index: number) => void)
        • (item, index): void
        • Parameters

          • item: any
          • index: number

          Returns void

    Returns void

  • Creates an array of values by iterating each element in the collection.

    -

    Type Parameters

    • T

    Parameters

    • iterator: ((item: any, index: number) => T)
        • (item, index): T
        • Parameters

          • item: any
          • index: number

          Returns T

    Returns T[]

  • Populates document references.

    -

    Parameters

    • expr: string | any[] | {
          model?: any;
          path?: string;
          [key: PropertyKey]: any;
      }

    Returns default<T>

  • Reduces a collection to a value which is the accumulated result of iterating +

    Parameters

    • iterator: ((item: any, index: number) => boolean)
        • (item, index): boolean
        • Parameters

          • item: any
          • index: number

          Returns boolean

    Returns default<T>

  • Iterates over all documents.

    +

    Parameters

    • iterator: ((item: any, index: number) => void)
        • (item, index): void
        • Parameters

          • item: any
          • index: number

          Returns void

    Returns void

  • Creates an array of values by iterating each element in the collection.

    +

    Type Parameters

    • T

    Parameters

    • iterator: ((item: any, index: number) => T)
        • (item, index): T
        • Parameters

          • item: any
          • index: number

          Returns T

    Returns T[]

  • Populates document references.

    +

    Parameters

    • expr: string | any[] | {
          model?: any;
          path?: string;
          [key: PropertyKey]: any;
      }

    Returns default<T>

  • Reduces a collection to a value which is the accumulated result of iterating each element in the collection.

    Type Parameters

    • R

    Parameters

    • iterator: ((pre: any, cur: any, index: number) => R)
        • (pre, cur, index): R
        • Parameters

          • pre: any
          • cur: any
          • index: number

          Returns R

    • Optionalinitial: R

      By default, the initial value is the first document.

      -

    Returns R

  • Reduces a collection to a value which is the accumulated result of iterating +

Returns R

  • Reduces a collection to a value which is the accumulated result of iterating each element in the collection from right to left.

    Type Parameters

    • R

    Parameters

    • iterator: ((pre: any, cur: any, index: number) => R)
        • (pre, cur, index): R
        • Parameters

          • pre: any
          • cur: any
          • index: number

          Returns R

    • Optionalinitial: R

      By default, the initial value is the last document.

      -

    Returns R

  • Remove all documents.

    -

    Parameters

    Returns Bluebird<any>

  • Replace all documents.

    -

    Parameters

    Returns Bluebird<any>

  • Returns the specified range of documents.

    -

    Parameters

    • start: number
    • Optionalend: number

    Returns default<T>

  • Tests whether some documents pass the test implemented by the provided +

Returns R

  • Remove all documents.

    +

    Parameters

    Returns Bluebird<any>

  • Replace all documents.

    +

    Parameters

    Returns Bluebird<any>

  • Returns the specified range of documents.

    +

    Parameters

    • start: number
    • Optionalend: number

    Returns default<T>

  • Tests whether some documents pass the test implemented by the provided function.

    -

    Parameters

    • iterator: ((item: any, index: number) => boolean)
        • (item, index): boolean
        • Parameters

          • item: any
          • index: number

          Returns boolean

    Returns boolean

  • Sorts documents.

    +

    Parameters

    • iterator: ((item: any, index: number) => boolean)
        • (item, index): boolean
        • Parameters

          • item: any
          • index: number

          Returns boolean

    Returns boolean

  • Sorts documents.

    Example:

    query.sort('date', -1);
    query.sort({date: -1, title: 1});
    query.sort('-date title');

    If the order equals to -1, desc or descending, the data will be returned in reversed order.

    -

    Parameters

    • orderby: string | object
    • Optionalorder: string | number | object

    Returns default<T>

  • Update all documents.

    -

    Parameters

    Returns Bluebird<any>

\ No newline at end of file +

Parameters

  • orderby: string | object
  • Optionalorder: string | number | object

Returns default<T>

  • Update all documents.

    +

    Parameters

    Returns Bluebird<any>

diff --git a/classes/schema.default.html b/classes/schema.default.html index 0a34b930..6ea2c8c1 100644 --- a/classes/schema.default.html +++ b/classes/schema.default.html @@ -1,4 +1,4 @@ -default | hexojs/warehouse

Type Parameters

  • T = any

Constructors

constructor +default | hexojs/warehouse

Type Parameters

  • T = any

Constructors

Properties

Types hooks methods @@ -14,13 +14,13 @@ static virtual

Constructors

Properties

Types: types
hooks: {
    post: {
        remove: ((...args: any[]) => Bluebird<any>)[];
        save: ((...args: any[]) => Bluebird<any>)[];
    };
    pre: {
        remove: ((...args: any[]) => Bluebird<any>)[];
        save: ((...args: any[]) => Bluebird<any>)[];
    };
}
methods: Record<string, ((this: T, ...args: any[]) => any)> = {}
paths: Record<string, default<any>> = {}
stacks: {
    export: ((data: object) => void)[];
    getter: ((data: object) => void)[];
    import: ((data: object) => void)[];
    setter: ((data: object) => void)[];
}
statics: Record<string, ((this: default<T>, ...args: any[]) => any)> = {}
Types: types = Types

Methods

  • Adds a instance method.

    -

    Parameters

    • name: string
    • fn: ((this: T, ...args: any[]) => any)
        • (this, ...args): any
        • Parameters

          • this: T
          • Rest...args: any[]

          Returns any

    Returns void

Properties

Types: types
hooks: {
    post: {
        remove: ((...args: any[]) => Bluebird<any>)[];
        save: ((...args: any[]) => Bluebird<any>)[];
    };
    pre: {
        remove: ((...args: any[]) => Bluebird<any>)[];
        save: ((...args: any[]) => Bluebird<any>)[];
    };
}
methods: Record<string, ((this: T, ...args: any[]) => any)> = {}
paths: Record<string, default<any>> = {}
stacks: {
    export: ((data: object) => void)[];
    getter: ((data: object) => void)[];
    import: ((data: object) => void)[];
    setter: ((data: object) => void)[];
}
statics: Record<string, ((this: default<T>, ...args: any[]) => any)> = {}
Types: types = Types

Methods

  • Adds a instance method.

    +

    Parameters

    • name: string
    • fn: ((this: T, ...args: any[]) => any)
        • (this, ...args): any
        • Parameters

          • this: T
          • Rest...args: any[]

          Returns any

    Returns void

  • Adds a post-hook.

    Parameters

    • type: "remove" | "save"

      Hook type. One of save or remove.

      -
    • fn: ((...args: any[]) => void)
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns void

  • Adds a pre-hook.

    +
  • fn: ((...args: any[]) => void)
      • (...args): void
      • Parameters

        • Rest...args: any[]

        Returns void

Returns void

  • Adds a pre-hook.

    Parameters

    • type: "remove" | "save"

      Hook type. One of save or remove.

      -
    • fn: ((...args: any[]) => void)
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns void

  • Adds a static method.

    -

    Parameters

    • name: string
    • fn: ((this: default<T>, ...args: any[]) => any)
        • (this, ...args): any
        • Parameters

          Returns any

    Returns void

  • Adds a virtual path.

    -

    Parameters

    • name: string
    • Optionalgetter: ((this: T) => any)
        • (this): any
        • Parameters

          • this: T

          Returns any

    Returns default<T>

\ No newline at end of file +
  • fn: ((...args: any[]) => void)
      • (...args): void
      • Parameters

        • Rest...args: any[]

        Returns void

  • Returns void

    • Adds a static method.

      +

      Parameters

      • name: string
      • fn: ((this: default<T>, ...args: any[]) => any)
          • (this, ...args): any
          • Parameters

            Returns any

      Returns void

    • Adds a virtual path.

      +

      Parameters

      • name: string
      • Optionalgetter: ((this: T) => any)
          • (this): any
          • Parameters

            • this: T

            Returns any

      Returns default<T>

    diff --git a/classes/schematype.default.html b/classes/schematype.default.html index de921e13..ccff6d61 100644 --- a/classes/schematype.default.html +++ b/classes/schematype.default.html @@ -24,7 +24,7 @@ is the value passed to the update operator; the data parameter is the complete data.

    The return value will replace the original data.

    -

    Type Parameters

    • T

    Hierarchy (view full)

    Constructors

    Type Parameters

    • T

    Hierarchy (view full)

    Constructors

    Properties

    default name options @@ -49,25 +49,25 @@ validate value

    Constructors

    • SchemaType constructor.

      -

      Type Parameters

      • T

      Parameters

      • name: string = ''
      • Optionaloptions: {
            default?: T | (() => T);
            required?: boolean;
        }
        • Optionaldefault?: T | (() => T)
        • Optionalrequired?: boolean

      Returns default<T>

    Properties

    default: (() => T)
    name: string = ''
    options: {
        default?: T | (() => T);
        required: boolean;
    }
    q$exists: ((value: unknown, query: unknown, data?: unknown) => boolean)

    Type declaration

      • (value, query, data?): boolean
      • Checks the existance of data.

        -

        Parameters

        • value: unknown
        • query: unknown
        • Optionaldata: unknown

        Returns boolean

    q$max: ((value: unknown, query: unknown, data?: unknown) => boolean)

    Type declaration

      • (value, query, data?): boolean
      • Checks whether value is less than or equal to (i.e. <=) the query.

        -

        Parameters

        • value: unknown
        • query: unknown
        • Optionaldata: unknown

        Returns boolean

    q$min: ((value: unknown, query: unknown, data?: unknown) => boolean)

    Type declaration

      • (value, query, data?): boolean
      • Checks whether value is greater than or equal to (i.e. >=) the query.

        -

        Parameters

        • value: unknown
        • query: unknown
        • Optionaldata: unknown

        Returns boolean

    Methods

    • Casts data. This function is used by getters to cast an object to document +

      Type Parameters

      • T

      Parameters

      • name: string = ''
      • Optionaloptions: {
            default?: T | (() => T);
            required?: boolean;
        }
        • Optionaldefault?: T | (() => T)
        • Optionalrequired?: boolean

      Returns default<T>

    Properties

    default: (() => T)
    name: string = ''
    options: {
        default?: T | (() => T);
        required: boolean;
    }
    q$exists: ((value: unknown, query: unknown, data?: unknown) => boolean)

    Type declaration

      • (value, query, data?): boolean
      • Checks the existance of data.

        +

        Parameters

        • value: unknown
        • query: unknown
        • Optionaldata: unknown

        Returns boolean

    q$max: ((value: unknown, query: unknown, data?: unknown) => boolean)

    Type declaration

      • (value, query, data?): boolean
      • Checks whether value is less than or equal to (i.e. <=) the query.

        +

        Parameters

        • value: unknown
        • query: unknown
        • Optionaldata: unknown

        Returns boolean

    q$min: ((value: unknown, query: unknown, data?: unknown) => boolean)

    Type declaration

      • (value, query, data?): boolean
      • Checks whether value is greater than or equal to (i.e. >=) the query.

        +

        Parameters

        • value: unknown
        • query: unknown
        • Optionaldata: unknown

        Returns boolean

    Methods

    • Casts data. This function is used by getters to cast an object to document instances. If the value is null, the default value will be returned.

      -

      Parameters

      • Optionalvalue: unknown
      • Optionaldata: unknown

      Returns unknown

    • Compares data. This function is used when sorting.

      -

      Parameters

      • a: unknown
      • b: unknown

      Returns number

    • Checks the equality of data.

      -

      Parameters

      • value: T
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Parses data. This function is used when restoring data from database files.

      -

      Parameters

      • value: unknown

      Returns any

    • Checks the existance of data.

      -

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is greater than (i.e. >) the query.

      -

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is greater than or equal to (i.e. >=) the query.

      -

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is equal to one of elements in query.

      -

      Parameters

      • value: unknown
      • query: unknown[]
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is less than (i.e. <) the query.

      -

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is less than or equal to (i.e. <=) the query.

      -

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks the equality of data. Returns true if the value doesn't match.

      -

      Parameters

      • value: T
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is not equal to any elements in query.

      -

      Parameters

      • value: unknown
      • query: unknown[]
      • Optionaldata: unknown

      Returns boolean

    • Renames a field.

      -

      Parameters

      • value: unknown
      • update: unknown
      • data: unknown

      Returns void

    • Sets the value.

      -

      Type Parameters

      • T

      Parameters

      • value: unknown
      • update: T
      • Optionaldata: unknown

      Returns T

    • Unsets the value.

      -

      Type Parameters

      • T

      Parameters

      • value: T
      • update: boolean
      • Optionaldata: unknown

      Returns T

    • Validates data. This function is used by setters.

      -

      Parameters

      • value: unknown
      • Optionaldata: unknown

      Returns unknown

    • Transforms value. This function is used when saving data to database files.

      -

      Parameters

      • value: unknown
      • Optionaldata: unknown

      Returns any

    \ No newline at end of file +

    Parameters

    • Optionalvalue: unknown
    • Optionaldata: unknown

    Returns unknown

    • Compares data. This function is used when sorting.

      +

      Parameters

      • a: unknown
      • b: unknown

      Returns number

    • Checks the equality of data.

      +

      Parameters

      • value: T
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Parses data. This function is used when restoring data from database files.

      +

      Parameters

      • value: unknown

      Returns any

    • Checks the existance of data.

      +

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is greater than (i.e. >) the query.

      +

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is greater than or equal to (i.e. >=) the query.

      +

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is equal to one of elements in query.

      +

      Parameters

      • value: unknown
      • query: unknown[]
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is less than (i.e. <) the query.

      +

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is less than or equal to (i.e. <=) the query.

      +

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks the equality of data. Returns true if the value doesn't match.

      +

      Parameters

      • value: T
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is not equal to any elements in query.

      +

      Parameters

      • value: unknown
      • query: unknown[]
      • Optionaldata: unknown

      Returns boolean

    • Renames a field.

      +

      Parameters

      • value: unknown
      • update: unknown
      • data: unknown

      Returns void

    • Sets the value.

      +

      Type Parameters

      • T

      Parameters

      • value: unknown
      • update: T
      • Optionaldata: unknown

      Returns T

    • Unsets the value.

      +

      Type Parameters

      • T

      Parameters

      • value: T
      • update: boolean
      • Optionaldata: unknown

      Returns T

    • Validates data. This function is used by setters.

      +

      Parameters

      • value: unknown
      • Optionaldata: unknown

      Returns unknown

    • Transforms value. This function is used when saving data to database files.

      +

      Parameters

      • value: unknown
      • Optionaldata: unknown

      Returns any

    diff --git a/classes/types_array.default.html b/classes/types_array.default.html index f5f621fa..e0aa5690 100644 --- a/classes/types_array.default.html +++ b/classes/types_array.default.html @@ -1,5 +1,5 @@ default | hexojs/warehouse

    Array schema type.

    -

    Type Parameters

    Hierarchy (view full)

    Constructors

    Type Parameters

    Hierarchy (view full)

    Constructors

    Properties

    child default name @@ -35,39 +35,39 @@ u$unshift validate value -

    Constructors

    Properties

    child: T
    default: (() => I[])
    name: string = ''
    options: {
        default?: I[] | (() => I[]);
        required: boolean;
    } & {
        child?: T;
    }
    q$exists: ((value: unknown, query: unknown, data?: unknown) => boolean)

    Type declaration

      • (value, query, data?): boolean
      • Checks the existance of data.

        -

        Parameters

        • value: unknown
        • query: unknown
        • Optionaldata: unknown

        Returns boolean

    q$length: ((value?: unknown[], query?: unknown, data?: unknown) => boolean)

    Type declaration

      • (value?, query?, data?): boolean
      • Checks whether the number of elements in an array is equal to query.

        -

        Parameters

        • Optionalvalue: unknown[]
        • Optionalquery: unknown
        • Optionaldata: unknown

        Returns boolean

    q$max: ((value: unknown, query: unknown, data?: unknown) => boolean)

    Type declaration

      • (value, query, data?): boolean
      • Checks whether value is less than or equal to (i.e. <=) the query.

        -

        Parameters

        • value: unknown
        • query: unknown
        • Optionaldata: unknown

        Returns boolean

    q$min: ((value: unknown, query: unknown, data?: unknown) => boolean)

    Type declaration

      • (value, query, data?): boolean
      • Checks whether value is greater than or equal to (i.e. >=) the query.

        -

        Parameters

        • value: unknown
        • query: unknown
        • Optionaldata: unknown

        Returns boolean

    u$append: (<T>(value?: T[], update?: T | T[], data?: unknown) => T[])

    Type declaration

      • <T>(value?, update?, data?): T[]
      • Add elements to an array.

        -

        Type Parameters

        • T

        Parameters

        • Optionalvalue: T[]
        • Optionalupdate: T | T[]
        • Optionaldata: unknown

        Returns T[]

    u$prepend: (<T>(value?: T[], update?: T | T[], data?: unknown) => T[])

    Type declaration

      • <T>(value?, update?, data?): T[]
      • Add elements in front of an array.

        -

        Type Parameters

        • T

        Parameters

        • Optionalvalue: T[]
        • Optionalupdate: T | T[]
        • Optionaldata: unknown

        Returns T[]

    Methods

    • Casts an array and its child elements.

      -

      Parameters

      • value_: unknown
      • Optionaldata: unknown

      Returns I[]

    • Casts data. This function is used by getters to cast an object to document +

    Constructors

    Properties

    child: T
    default: (() => I[])
    name: string = ''
    options: {
        default?: I[] | (() => I[]);
        required: boolean;
    } & {
        child?: T;
    }
    q$exists: ((value: unknown, query: unknown, data?: unknown) => boolean)

    Type declaration

      • (value, query, data?): boolean
      • Checks the existance of data.

        +

        Parameters

        • value: unknown
        • query: unknown
        • Optionaldata: unknown

        Returns boolean

    q$length: ((value?: unknown[], query?: unknown, data?: unknown) => boolean)

    Type declaration

      • (value?, query?, data?): boolean
      • Checks whether the number of elements in an array is equal to query.

        +

        Parameters

        • Optionalvalue: unknown[]
        • Optionalquery: unknown
        • Optionaldata: unknown

        Returns boolean

    q$max: ((value: unknown, query: unknown, data?: unknown) => boolean)

    Type declaration

      • (value, query, data?): boolean
      • Checks whether value is less than or equal to (i.e. <=) the query.

        +

        Parameters

        • value: unknown
        • query: unknown
        • Optionaldata: unknown

        Returns boolean

    q$min: ((value: unknown, query: unknown, data?: unknown) => boolean)

    Type declaration

      • (value, query, data?): boolean
      • Checks whether value is greater than or equal to (i.e. >=) the query.

        +

        Parameters

        • value: unknown
        • query: unknown
        • Optionaldata: unknown

        Returns boolean

    u$append: (<T>(value?: T[], update?: T | T[], data?: unknown) => T[])

    Type declaration

      • <T>(value?, update?, data?): T[]
      • Add elements to an array.

        +

        Type Parameters

        • T

        Parameters

        • Optionalvalue: T[]
        • Optionalupdate: T | T[]
        • Optionaldata: unknown

        Returns T[]

    u$prepend: (<T>(value?: T[], update?: T | T[], data?: unknown) => T[])

    Type declaration

      • <T>(value?, update?, data?): T[]
      • Add elements in front of an array.

        +

        Type Parameters

        • T

        Parameters

        • Optionalvalue: T[]
        • Optionalupdate: T | T[]
        • Optionaldata: unknown

        Returns T[]

    Methods

    • Casts an array and its child elements.

      +

      Parameters

      • value_: unknown
      • Optionaldata: unknown

      Returns I[]

    • Casts data. This function is used by getters to cast an object to document instances. If the value is null, the default value will be returned.

      -

      Parameters

      • Optionalvalue_: unknown
      • Optionaldata: unknown

      Returns I[]

    • Compares an array by its child elements and the size of the array.

      -

      Parameters

      • Optionala: I[]
      • Optionalb: I[]

      Returns number

    • Checks the equality of an array.

      -

      Parameters

      • Optionalvalue: I[]
      • Optionalquery: unknown[]
      • Optionaldata: unknown

      Returns boolean

    • Parses data.

      -

      Parameters

      • value: unknown[]

      Returns I[]

    • Parses data. This function is used when restoring data from database files.

      -

      Returns undefined

    • Checks whether an array contains all elements in query.

      -

      Type Parameters

      • T

      Parameters

      • Optionalvalue: T[]
      • Optionalquery: T[]
      • Optionaldata: unknown

      Returns boolean

    • Checks the existance of data.

      -

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is greater than (i.e. >) the query.

      -

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is greater than or equal to (i.e. >=) the query.

      -

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether an array contains one of elements in query.

      -

      Parameters

      • Optionalvalue: unknown[]
      • Optionalquery: unknown[]
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is less than (i.e. <) the query.

      -

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is less than or equal to (i.e. <=) the query.

      -

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks the equality of data. Returns true if the value doesn't match.

      -

      Parameters

      • value: I[]
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether an array does not contain in any elements in query.

      -

      Type Parameters

      • T

      Parameters

      • Optionalvalue: T[]
      • Optionalquery: T[]
      • Optionaldata: unknown

      Returns boolean

    • Checks whether the number of elements in an array is equal to query.

      -

      Parameters

      • Optionalvalue: unknown[]
      • Optionalquery: unknown
      • Optionaldata: unknown

      Returns boolean

    • Add elements to an array only if the value is not already in the array.

      -

      Type Parameters

      • T

      Parameters

      • Optionalvalue: T[]
      • Optionalupdate: T | T[]
      • Optionaldata: unknown

      Returns T[]

    • Removes the last element from an array.

      -

      Type Parameters

      • T

      Parameters

      • Optionalvalue: T[]
      • Optionalupdate: number | boolean
      • Optionaldata: unknown

      Returns T[]

    • Removes elements from an array.

      -

      Type Parameters

      • T

      Parameters

      • Optionalvalue: T[]
      • Optionalupdate: T | T[]
      • Optionaldata: unknown

      Returns T[]

    • Add elements to an array.

      -

      Type Parameters

      • T

      Parameters

      • Optionalvalue: T[]
      • Optionalupdate: T | T[]
      • Optionaldata: unknown

      Returns T[]

    • Renames a field.

      -

      Parameters

      • value: unknown
      • update: unknown
      • data: unknown

      Returns void

    • Sets the value.

      -

      Type Parameters

      • T

      Parameters

      • value: unknown
      • update: T
      • Optionaldata: unknown

      Returns T

    • Removes the first element from an array.

      -

      Type Parameters

      • T

      Parameters

      • Optionalvalue: T[]
      • Optionalupdate: number | boolean
      • Optionaldata: unknown

      Returns T[]

    • Unsets the value.

      -

      Type Parameters

      • T

      Parameters

      • value: T
      • update: boolean
      • Optionaldata: unknown

      Returns T

    • Add elements in front of an array.

      -

      Type Parameters

      • T

      Parameters

      • Optionalvalue: T[]
      • Optionalupdate: T | T[]
      • Optionaldata: unknown

      Returns T[]

    • Validates an array and its child elements.

      -

      Parameters

      • Optionalvalue_: unknown
      • Optionaldata: unknown

      Returns I[]

    • Transforms data.

      -

      Parameters

      • value: unknown[]
      • Optionaldata: unknown

      Returns any[]

    • Transforms value. This function is used when saving data to database files.

      -

      Returns undefined

    \ No newline at end of file +

    Parameters

    • Optionalvalue_: unknown
    • Optionaldata: unknown

    Returns I[]

    • Compares an array by its child elements and the size of the array.

      +

      Parameters

      • Optionala: I[]
      • Optionalb: I[]

      Returns number

    • Checks the equality of an array.

      +

      Parameters

      • Optionalvalue: I[]
      • Optionalquery: unknown[]
      • Optionaldata: unknown

      Returns boolean

    • Parses data.

      +

      Parameters

      • value: unknown[]

      Returns I[]

    • Parses data. This function is used when restoring data from database files.

      +

      Returns undefined

    • Checks whether an array contains all elements in query.

      +

      Type Parameters

      • T

      Parameters

      • Optionalvalue: T[]
      • Optionalquery: T[]
      • Optionaldata: unknown

      Returns boolean

    • Checks the existance of data.

      +

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is greater than (i.e. >) the query.

      +

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is greater than or equal to (i.e. >=) the query.

      +

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether an array contains one of elements in query.

      +

      Parameters

      • Optionalvalue: unknown[]
      • Optionalquery: unknown[]
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is less than (i.e. <) the query.

      +

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is less than or equal to (i.e. <=) the query.

      +

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks the equality of data. Returns true if the value doesn't match.

      +

      Parameters

      • value: I[]
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether an array does not contain in any elements in query.

      +

      Type Parameters

      • T

      Parameters

      • Optionalvalue: T[]
      • Optionalquery: T[]
      • Optionaldata: unknown

      Returns boolean

    • Checks whether the number of elements in an array is equal to query.

      +

      Parameters

      • Optionalvalue: unknown[]
      • Optionalquery: unknown
      • Optionaldata: unknown

      Returns boolean

    • Add elements to an array only if the value is not already in the array.

      +

      Type Parameters

      • T

      Parameters

      • Optionalvalue: T[]
      • Optionalupdate: T | T[]
      • Optionaldata: unknown

      Returns T[]

    • Removes the last element from an array.

      +

      Type Parameters

      • T

      Parameters

      • Optionalvalue: T[]
      • Optionalupdate: number | boolean
      • Optionaldata: unknown

      Returns T[]

    • Removes elements from an array.

      +

      Type Parameters

      • T

      Parameters

      • Optionalvalue: T[]
      • Optionalupdate: T | T[]
      • Optionaldata: unknown

      Returns T[]

    • Add elements to an array.

      +

      Type Parameters

      • T

      Parameters

      • Optionalvalue: T[]
      • Optionalupdate: T | T[]
      • Optionaldata: unknown

      Returns T[]

    • Renames a field.

      +

      Parameters

      • value: unknown
      • update: unknown
      • data: unknown

      Returns void

    • Sets the value.

      +

      Type Parameters

      • T

      Parameters

      • value: unknown
      • update: T
      • Optionaldata: unknown

      Returns T

    • Removes the first element from an array.

      +

      Type Parameters

      • T

      Parameters

      • Optionalvalue: T[]
      • Optionalupdate: number | boolean
      • Optionaldata: unknown

      Returns T[]

    • Unsets the value.

      +

      Type Parameters

      • T

      Parameters

      • value: T
      • update: boolean
      • Optionaldata: unknown

      Returns T

    • Add elements in front of an array.

      +

      Type Parameters

      • T

      Parameters

      • Optionalvalue: T[]
      • Optionalupdate: T | T[]
      • Optionaldata: unknown

      Returns T[]

    • Validates an array and its child elements.

      +

      Parameters

      • Optionalvalue_: unknown
      • Optionaldata: unknown

      Returns I[]

    • Transforms data.

      +

      Parameters

      • value: unknown[]
      • Optionaldata: unknown

      Returns any[]

    • Transforms value. This function is used when saving data to database files.

      +

      Returns undefined

    diff --git a/classes/types_boolean.default.html b/classes/types_boolean.default.html index 7b4413c9..ce4082bc 100644 --- a/classes/types_boolean.default.html +++ b/classes/types_boolean.default.html @@ -1,5 +1,5 @@ default | hexojs/warehouse

    Boolean schema type.

    -

    Hierarchy (view full)

    Constructors

    Hierarchy (view full)

    Constructors

    Properties

    default name options @@ -24,24 +24,24 @@ validate value

    Constructors

    • SchemaType constructor.

      -

      Parameters

      • name: string = ''
      • Optionaloptions: {
            default?: boolean | (() => boolean);
            required?: boolean;
        }
        • Optionaldefault?: boolean | (() => boolean)
        • Optionalrequired?: boolean

      Returns default

    Properties

    default: (() => boolean)
    name: string = ''
    options: {
        default?: boolean | (() => boolean);
        required: boolean;
    }
    q$exists: ((value: unknown, query: unknown, data?: unknown) => boolean)

    Type declaration

      • (value, query, data?): boolean
      • Checks the existance of data.

        -

        Parameters

        • value: unknown
        • query: unknown
        • Optionaldata: unknown

        Returns boolean

    q$max: ((value: unknown, query: unknown, data?: unknown) => boolean)

    Type declaration

      • (value, query, data?): boolean
      • Checks whether value is less than or equal to (i.e. <=) the query.

        -

        Parameters

        • value: unknown
        • query: unknown
        • Optionaldata: unknown

        Returns boolean

    q$min: ((value: unknown, query: unknown, data?: unknown) => boolean)

    Type declaration

      • (value, query, data?): boolean
      • Checks whether value is greater than or equal to (i.e. >=) the query.

        -

        Parameters

        • value: unknown
        • query: unknown
        • Optionaldata: unknown

        Returns boolean

    Methods

    • Casts a boolean.

      -

      Parameters

      • Optionalvalue_: unknown
      • Optionaldata: unknown

      Returns boolean

    • Compares data. This function is used when sorting.

      -

      Parameters

      • a: unknown
      • b: unknown

      Returns number

    • Checks the equality of data.

      -

      Parameters

      • value: boolean
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Parses data and transform them into boolean values.

      -

      Parameters

      • value: unknown

      Returns boolean

    • Checks the existance of data.

      -

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is greater than (i.e. >) the query.

      -

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is greater than or equal to (i.e. >=) the query.

      -

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is equal to one of elements in query.

      -

      Parameters

      • value: unknown
      • query: unknown[]
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is less than (i.e. <) the query.

      -

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is less than or equal to (i.e. <=) the query.

      -

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks the equality of data. Returns true if the value doesn't match.

      -

      Parameters

      • value: boolean
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is not equal to any elements in query.

      -

      Parameters

      • value: unknown
      • query: unknown[]
      • Optionaldata: unknown

      Returns boolean

    • Renames a field.

      -

      Parameters

      • value: unknown
      • update: unknown
      • data: unknown

      Returns void

    • Sets the value.

      -

      Type Parameters

      • T

      Parameters

      • value: unknown
      • update: T
      • Optionaldata: unknown

      Returns T

    • Unsets the value.

      -

      Type Parameters

      • T

      Parameters

      • value: T
      • update: boolean
      • Optionaldata: unknown

      Returns T

    • Validates a boolean.

      -

      Parameters

      • value_: unknown
      • Optionaldata: unknown

      Returns boolean

    • Transforms data into number to compress the size of database files.

      -

      Parameters

      • value: unknown

      Returns number

    \ No newline at end of file +

    Parameters

    • name: string = ''
    • Optionaloptions: {
          default?: boolean | (() => boolean);
          required?: boolean;
      }
      • Optionaldefault?: boolean | (() => boolean)
      • Optionalrequired?: boolean

    Returns default

    Properties

    default: (() => boolean)
    name: string = ''
    options: {
        default?: boolean | (() => boolean);
        required: boolean;
    }
    q$exists: ((value: unknown, query: unknown, data?: unknown) => boolean)

    Type declaration

      • (value, query, data?): boolean
      • Checks the existance of data.

        +

        Parameters

        • value: unknown
        • query: unknown
        • Optionaldata: unknown

        Returns boolean

    q$max: ((value: unknown, query: unknown, data?: unknown) => boolean)

    Type declaration

      • (value, query, data?): boolean
      • Checks whether value is less than or equal to (i.e. <=) the query.

        +

        Parameters

        • value: unknown
        • query: unknown
        • Optionaldata: unknown

        Returns boolean

    q$min: ((value: unknown, query: unknown, data?: unknown) => boolean)

    Type declaration

      • (value, query, data?): boolean
      • Checks whether value is greater than or equal to (i.e. >=) the query.

        +

        Parameters

        • value: unknown
        • query: unknown
        • Optionaldata: unknown

        Returns boolean

    Methods

    • Casts a boolean.

      +

      Parameters

      • Optionalvalue_: unknown
      • Optionaldata: unknown

      Returns boolean

    • Compares data. This function is used when sorting.

      +

      Parameters

      • a: unknown
      • b: unknown

      Returns number

    • Checks the equality of data.

      +

      Parameters

      • value: boolean
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Parses data and transform them into boolean values.

      +

      Parameters

      • value: unknown

      Returns boolean

    • Checks the existance of data.

      +

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is greater than (i.e. >) the query.

      +

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is greater than or equal to (i.e. >=) the query.

      +

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is equal to one of elements in query.

      +

      Parameters

      • value: unknown
      • query: unknown[]
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is less than (i.e. <) the query.

      +

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is less than or equal to (i.e. <=) the query.

      +

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks the equality of data. Returns true if the value doesn't match.

      +

      Parameters

      • value: boolean
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is not equal to any elements in query.

      +

      Parameters

      • value: unknown
      • query: unknown[]
      • Optionaldata: unknown

      Returns boolean

    • Renames a field.

      +

      Parameters

      • value: unknown
      • update: unknown
      • data: unknown

      Returns void

    • Sets the value.

      +

      Type Parameters

      • T

      Parameters

      • value: unknown
      • update: T
      • Optionaldata: unknown

      Returns T

    • Unsets the value.

      +

      Type Parameters

      • T

      Parameters

      • value: T
      • update: boolean
      • Optionaldata: unknown

      Returns T

    • Validates a boolean.

      +

      Parameters

      • value_: unknown
      • Optionaldata: unknown

      Returns boolean

    • Transforms data into number to compress the size of database files.

      +

      Parameters

      • value: unknown

      Returns number

    diff --git a/classes/types_buffer.default.html b/classes/types_buffer.default.html index 9148997b..616a30d8 100644 --- a/classes/types_buffer.default.html +++ b/classes/types_buffer.default.html @@ -1,5 +1,5 @@ default | hexojs/warehouse

    Boolean schema type.

    -

    Hierarchy (view full)

    Constructors

    Hierarchy (view full)

    Constructors

    Properties

    default name options @@ -23,27 +23,27 @@ u$unset validate value -

    Constructors

    • Parameters

      • name: string
      • Optionaloptions: Partial<{
            default?: Buffer | (() => Buffer);
            required: boolean;
        }> & {
            encoding?: BufferEncoding;
        }

      Returns default

    Properties

    default: (() => Buffer)
    name: string = ''
    options: {
        default?: Buffer | (() => Buffer);
        required: boolean;
    } & {
        encoding: BufferEncoding;
    }
    q$exists: ((value: unknown, query: unknown, data?: unknown) => boolean)

    Type declaration

      • (value, query, data?): boolean
      • Checks the existance of data.

        -

        Parameters

        • value: unknown
        • query: unknown
        • Optionaldata: unknown

        Returns boolean

    q$max: ((value: unknown, query: unknown, data?: unknown) => boolean)

    Type declaration

      • (value, query, data?): boolean
      • Checks whether value is less than or equal to (i.e. <=) the query.

        -

        Parameters

        • value: unknown
        • query: unknown
        • Optionaldata: unknown

        Returns boolean

    q$min: ((value: unknown, query: unknown, data?: unknown) => boolean)

    Type declaration

      • (value, query, data?): boolean
      • Checks whether value is greater than or equal to (i.e. >=) the query.

        -

        Parameters

        • value: unknown
        • query: unknown
        • Optionaldata: unknown

        Returns boolean

    Methods

    • Casts data.

      -

      Parameters

      • value_: WithImplicitCoercion<string | Uint8Array | readonly number[]>
      • Optionaldata: unknown

      Returns Buffer

    • Casts data. This function is used by getters to cast an object to document +

    Constructors

    • Parameters

      • name: string
      • Optionaloptions: Partial<{
            default?: Buffer | (() => Buffer);
            required: boolean;
        }> & {
            encoding?: BufferEncoding;
        }

      Returns default

    Properties

    default: (() => Buffer)
    name: string = ''
    options: {
        default?: Buffer | (() => Buffer);
        required: boolean;
    } & {
        encoding: BufferEncoding;
    }
    q$exists: ((value: unknown, query: unknown, data?: unknown) => boolean)

    Type declaration

      • (value, query, data?): boolean
      • Checks the existance of data.

        +

        Parameters

        • value: unknown
        • query: unknown
        • Optionaldata: unknown

        Returns boolean

    q$max: ((value: unknown, query: unknown, data?: unknown) => boolean)

    Type declaration

      • (value, query, data?): boolean
      • Checks whether value is less than or equal to (i.e. <=) the query.

        +

        Parameters

        • value: unknown
        • query: unknown
        • Optionaldata: unknown

        Returns boolean

    q$min: ((value: unknown, query: unknown, data?: unknown) => boolean)

    Type declaration

      • (value, query, data?): boolean
      • Checks whether value is greater than or equal to (i.e. >=) the query.

        +

        Parameters

        • value: unknown
        • query: unknown
        • Optionaldata: unknown

        Returns boolean

    Methods

    • Casts data.

      +

      Parameters

      • value_: WithImplicitCoercion<string | Uint8Array | readonly number[]>
      • Optionaldata: unknown

      Returns Buffer

    • Casts data. This function is used by getters to cast an object to document instances. If the value is null, the default value will be returned.

      -

      Parameters

      • Optionalvalue_: unknown
      • Optionaldata: unknown

      Returns Buffer

    • Compares between two buffers.

      -

      Parameters

      • Optionala: Buffer
      • Optionalb: Buffer

      Returns number

    • Checks the equality of data.

      -

      Parameters

      • value: Buffer
      • query: Buffer

      Returns boolean

    • Parses data and transform them into buffer values.

      -

      Parameters

      • value: WithImplicitCoercion<string | Uint8Array | readonly number[]>

      Returns Buffer

    • Parses data. This function is used when restoring data from database files.

      -

      Parameters

      • Optionalvalue: unknown

      Returns Buffer

    • Checks the existance of data.

      -

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is greater than (i.e. >) the query.

      -

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is greater than or equal to (i.e. >=) the query.

      -

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is equal to one of elements in query.

      -

      Parameters

      • value: unknown
      • query: unknown[]
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is less than (i.e. <) the query.

      -

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is less than or equal to (i.e. <=) the query.

      -

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks the equality of data. Returns true if the value doesn't match.

      -

      Parameters

      • value: Buffer
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is not equal to any elements in query.

      -

      Parameters

      • value: unknown
      • query: unknown[]
      • Optionaldata: unknown

      Returns boolean

    • Renames a field.

      -

      Parameters

      • value: unknown
      • update: unknown
      • data: unknown

      Returns void

    • Sets the value.

      -

      Type Parameters

      • T

      Parameters

      • value: unknown
      • update: T
      • Optionaldata: unknown

      Returns T

    • Unsets the value.

      -

      Type Parameters

      • T

      Parameters

      • value: T
      • update: boolean
      • Optionaldata: unknown

      Returns T

    • Transforms data into number to compress the size of database files.

      -

      Parameters

      • Optionalvalue: Buffer

      Returns string

    \ No newline at end of file +

    Parameters

    • Optionalvalue_: unknown
    • Optionaldata: unknown

    Returns Buffer

    • Compares between two buffers.

      +

      Parameters

      • Optionala: Buffer
      • Optionalb: Buffer

      Returns number

    • Checks the equality of data.

      +

      Parameters

      • value: Buffer
      • query: Buffer

      Returns boolean

    • Parses data and transform them into buffer values.

      +

      Parameters

      • value: WithImplicitCoercion<string | Uint8Array | readonly number[]>

      Returns Buffer

    • Parses data. This function is used when restoring data from database files.

      +

      Parameters

      • Optionalvalue: unknown

      Returns Buffer

    • Checks the existance of data.

      +

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is greater than (i.e. >) the query.

      +

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is greater than or equal to (i.e. >=) the query.

      +

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is equal to one of elements in query.

      +

      Parameters

      • value: unknown
      • query: unknown[]
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is less than (i.e. <) the query.

      +

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is less than or equal to (i.e. <=) the query.

      +

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks the equality of data. Returns true if the value doesn't match.

      +

      Parameters

      • value: Buffer
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is not equal to any elements in query.

      +

      Parameters

      • value: unknown
      • query: unknown[]
      • Optionaldata: unknown

      Returns boolean

    • Renames a field.

      +

      Parameters

      • value: unknown
      • update: unknown
      • data: unknown

      Returns void

    • Sets the value.

      +

      Type Parameters

      • T

      Parameters

      • value: unknown
      • update: T
      • Optionaldata: unknown

      Returns T

    • Unsets the value.

      +

      Type Parameters

      • T

      Parameters

      • value: T
      • update: boolean
      • Optionaldata: unknown

      Returns T

    • Transforms data into number to compress the size of database files.

      +

      Parameters

      • Optionalvalue: Buffer

      Returns string

    diff --git a/classes/types_cuid.default.html b/classes/types_cuid.default.html index d829eb4b..ee7bb32b 100644 --- a/classes/types_cuid.default.html +++ b/classes/types_cuid.default.html @@ -1,5 +1,5 @@ default | hexojs/warehouse

    CUID schema type.

    -

    Hierarchy (view full)

    Constructors

    Hierarchy (view full)

    Constructors

    Properties

    default name options @@ -24,25 +24,25 @@ validate value

    Constructors

    • SchemaType constructor.

      -

      Parameters

      • name: string = ''
      • Optionaloptions: {
            default?: string | (() => string);
            required?: boolean;
        }
        • Optionaldefault?: string | (() => string)
        • Optionalrequired?: boolean

      Returns default

    Properties

    default: (() => string)
    name: string = ''
    options: {
        default?: string | (() => string);
        required: boolean;
    }
    q$exists: ((value: unknown, query: unknown, data?: unknown) => boolean)

    Type declaration

      • (value, query, data?): boolean
      • Checks the existance of data.

        -

        Parameters

        • value: unknown
        • query: unknown
        • Optionaldata: unknown

        Returns boolean

    q$max: ((value: unknown, query: unknown, data?: unknown) => boolean)

    Type declaration

      • (value, query, data?): boolean
      • Checks whether value is less than or equal to (i.e. <=) the query.

        -

        Parameters

        • value: unknown
        • query: unknown
        • Optionaldata: unknown

        Returns boolean

    q$min: ((value: unknown, query: unknown, data?: unknown) => boolean)

    Type declaration

      • (value, query, data?): boolean
      • Checks whether value is greater than or equal to (i.e. >=) the query.

        -

        Parameters

        • value: unknown
        • query: unknown
        • Optionaldata: unknown

        Returns boolean

    Methods

    • Casts data. Returns a new CUID only if value is null and the field is +

      Parameters

      • name: string = ''
      • Optionaloptions: {
            default?: string | (() => string);
            required?: boolean;
        }
        • Optionaldefault?: string | (() => string)
        • Optionalrequired?: boolean

      Returns default

    Properties

    default: (() => string)
    name: string = ''
    options: {
        default?: string | (() => string);
        required: boolean;
    }
    q$exists: ((value: unknown, query: unknown, data?: unknown) => boolean)

    Type declaration

      • (value, query, data?): boolean
      • Checks the existance of data.

        +

        Parameters

        • value: unknown
        • query: unknown
        • Optionaldata: unknown

        Returns boolean

    q$max: ((value: unknown, query: unknown, data?: unknown) => boolean)

    Type declaration

      • (value, query, data?): boolean
      • Checks whether value is less than or equal to (i.e. <=) the query.

        +

        Parameters

        • value: unknown
        • query: unknown
        • Optionaldata: unknown

        Returns boolean

    q$min: ((value: unknown, query: unknown, data?: unknown) => boolean)

    Type declaration

      • (value, query, data?): boolean
      • Checks whether value is greater than or equal to (i.e. >=) the query.

        +

        Parameters

        • value: unknown
        • query: unknown
        • Optionaldata: unknown

        Returns boolean

    Methods

    • Casts data. Returns a new CUID only if value is null and the field is required.

      -

      Parameters

      • Optionalvalue: string

      Returns string

    • Compares data. This function is used when sorting.

      -

      Parameters

      • a: unknown
      • b: unknown

      Returns number

    • Checks the equality of data.

      -

      Parameters

      • value: string
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Parses data. This function is used when restoring data from database files.

      -

      Parameters

      • value: unknown

      Returns any

    • Checks the existance of data.

      -

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is greater than (i.e. >) the query.

      -

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is greater than or equal to (i.e. >=) the query.

      -

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is equal to one of elements in query.

      -

      Parameters

      • value: unknown
      • query: unknown[]
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is less than (i.e. <) the query.

      -

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is less than or equal to (i.e. <=) the query.

      -

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks the equality of data. Returns true if the value doesn't match.

      -

      Parameters

      • value: string
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is not equal to any elements in query.

      -

      Parameters

      • value: unknown
      • query: unknown[]
      • Optionaldata: unknown

      Returns boolean

    • Renames a field.

      -

      Parameters

      • value: unknown
      • update: unknown
      • data: unknown

      Returns void

    • Sets the value.

      -

      Type Parameters

      • T

      Parameters

      • value: unknown
      • update: T
      • Optionaldata: unknown

      Returns T

    • Unsets the value.

      -

      Type Parameters

      • T

      Parameters

      • value: T
      • update: boolean
      • Optionaldata: unknown

      Returns T

    • Validates data. A valid CUID must be started with c and 25 in length.

      -

      Parameters

      • Optionalvalue: string

      Returns string

    • Transforms value. This function is used when saving data to database files.

      -

      Parameters

      • value: unknown
      • Optionaldata: unknown

      Returns any

    \ No newline at end of file +

    Parameters

    • Optionalvalue: string

    Returns string

    • Compares data. This function is used when sorting.

      +

      Parameters

      • a: unknown
      • b: unknown

      Returns number

    • Checks the equality of data.

      +

      Parameters

      • value: string
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Parses data. This function is used when restoring data from database files.

      +

      Parameters

      • value: unknown

      Returns any

    • Checks the existance of data.

      +

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is greater than (i.e. >) the query.

      +

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is greater than or equal to (i.e. >=) the query.

      +

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is equal to one of elements in query.

      +

      Parameters

      • value: unknown
      • query: unknown[]
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is less than (i.e. <) the query.

      +

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is less than or equal to (i.e. <=) the query.

      +

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks the equality of data. Returns true if the value doesn't match.

      +

      Parameters

      • value: string
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is not equal to any elements in query.

      +

      Parameters

      • value: unknown
      • query: unknown[]
      • Optionaldata: unknown

      Returns boolean

    • Renames a field.

      +

      Parameters

      • value: unknown
      • update: unknown
      • data: unknown

      Returns void

    • Sets the value.

      +

      Type Parameters

      • T

      Parameters

      • value: unknown
      • update: T
      • Optionaldata: unknown

      Returns T

    • Unsets the value.

      +

      Type Parameters

      • T

      Parameters

      • value: T
      • update: boolean
      • Optionaldata: unknown

      Returns T

    • Validates data. A valid CUID must be started with c and 25 in length.

      +

      Parameters

      • Optionalvalue: string

      Returns string

    • Transforms value. This function is used when saving data to database files.

      +

      Parameters

      • value: unknown
      • Optionaldata: unknown

      Returns any

    diff --git a/classes/types_date.default.html b/classes/types_date.default.html index 06109f66..3acd3171 100644 --- a/classes/types_date.default.html +++ b/classes/types_date.default.html @@ -1,5 +1,5 @@ default | hexojs/warehouse

    Date schema type.

    -

    Hierarchy (view full)

    Constructors

    Hierarchy (view full)

    Constructors

    Properties

    default name options @@ -29,33 +29,33 @@ validate value

    Constructors

    • SchemaType constructor.

      -

      Parameters

      • name: string = ''
      • Optionaloptions: {
            default?: Date | (() => Date);
            required?: boolean;
        }
        • Optionaldefault?: Date | (() => Date)
        • Optionalrequired?: boolean

      Returns default

    Properties

    default: (() => Date)
    name: string = ''
    options: {
        default?: Date | (() => Date);
        required: boolean;
    }
    q$exists: ((value: unknown, query: unknown, data?: unknown) => boolean)

    Type declaration

      • (value, query, data?): boolean
      • Checks the existance of data.

        -

        Parameters

        • value: unknown
        • query: unknown
        • Optionaldata: unknown

        Returns boolean

    q$max: ((value: unknown, query: unknown, data?: unknown) => boolean)

    Type declaration

      • (value, query, data?): boolean
      • Checks whether value is less than or equal to (i.e. <=) the query.

        -

        Parameters

        • value: unknown
        • query: unknown
        • Optionaldata: unknown

        Returns boolean

    q$min: ((value: unknown, query: unknown, data?: unknown) => boolean)

    Type declaration

      • (value, query, data?): boolean
      • Checks whether value is greater than or equal to (i.e. >=) the query.

        -

        Parameters

        • value: unknown
        • query: unknown
        • Optionaldata: unknown

        Returns boolean

    Methods

    • Casts data.

      -

      Parameters

      • value_: string | number | Date

      Returns Date

    • Casts data. This function is used by getters to cast an object to document +

      Parameters

      • name: string = ''
      • Optionaloptions: {
            default?: Date | (() => Date);
            required?: boolean;
        }
        • Optionaldefault?: Date | (() => Date)
        • Optionalrequired?: boolean

      Returns default

    Properties

    default: (() => Date)
    name: string = ''
    options: {
        default?: Date | (() => Date);
        required: boolean;
    }
    q$exists: ((value: unknown, query: unknown, data?: unknown) => boolean)

    Type declaration

      • (value, query, data?): boolean
      • Checks the existance of data.

        +

        Parameters

        • value: unknown
        • query: unknown
        • Optionaldata: unknown

        Returns boolean

    q$max: ((value: unknown, query: unknown, data?: unknown) => boolean)

    Type declaration

      • (value, query, data?): boolean
      • Checks whether value is less than or equal to (i.e. <=) the query.

        +

        Parameters

        • value: unknown
        • query: unknown
        • Optionaldata: unknown

        Returns boolean

    q$min: ((value: unknown, query: unknown, data?: unknown) => boolean)

    Type declaration

      • (value, query, data?): boolean
      • Checks whether value is greater than or equal to (i.e. >=) the query.

        +

        Parameters

        • value: unknown
        • query: unknown
        • Optionaldata: unknown

        Returns boolean

    Methods

    • Casts data.

      +

      Parameters

      • value_: string | number | Date

      Returns Date

    • Casts data. This function is used by getters to cast an object to document instances. If the value is null, the default value will be returned.

      -

      Parameters

      • Optionalvalue_: unknown

      Returns Date

    • Compares between two dates.

      -

      Parameters

      • Optionala: Date
      • Optionalb: Date

      Returns number

    • Checks the equality of data.

      -

      Parameters

      • value: Date
      • query: Date

      Returns boolean

    • Parses data and transforms it into a date object.

      -

      Parameters

      • value: string | number | Date

      Returns Date

    • Parses data. This function is used when restoring data from database files.

      -

      Returns undefined

    • Finds data by its date.

      -

      Parameters

      • value: Date
      • query: number

      Returns boolean

    • Checks the existance of data.

      -

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is greater than (i.e. >) the query.

      -

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is greater than or equal to (i.e. >=) the query.

      -

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is equal to one of elements in query.

      -

      Parameters

      • value: unknown
      • query: unknown[]
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is less than (i.e. <) the query.

      -

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is less than or equal to (i.e. <=) the query.

      -

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Finds data by its month. (Start from 0)

      -

      Parameters

      • value: Date
      • query: number

      Returns boolean

    • Checks the equality of data. Returns true if the value doesn't match.

      -

      Parameters

      • value: Date
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is not equal to any elements in query.

      -

      Parameters

      • value: unknown
      • query: unknown[]
      • Optionaldata: unknown

      Returns boolean

    • Finds data by its year. (4-digit)

      -

      Parameters

      • value: Date
      • query: number

      Returns boolean

    • Subtracts milliseconds from date.

      -

      Parameters

      • value: Date
      • update: number

      Returns Date

    • Adds milliseconds to date.

      -

      Parameters

      • value: Date
      • update: number

      Returns Date

    • Renames a field.

      -

      Parameters

      • value: unknown
      • update: unknown
      • data: unknown

      Returns void

    • Sets the value.

      -

      Type Parameters

      • T

      Parameters

      • value: unknown
      • update: T
      • Optionaldata: unknown

      Returns T

    • Unsets the value.

      -

      Type Parameters

      • T

      Parameters

      • value: T
      • update: boolean
      • Optionaldata: unknown

      Returns T

    • Validates data.

      -

      Parameters

      • value_: unknown
      • Optionaldata: unknown

      Returns Date

    • Transforms a date object to a string.

      -

      Parameters

      • value: Date

      Returns string

    • Transforms value. This function is used when saving data to database files.

      -

      Returns undefined

    \ No newline at end of file +

    Parameters

    • Optionalvalue_: unknown

    Returns Date

    • Compares between two dates.

      +

      Parameters

      • Optionala: Date
      • Optionalb: Date

      Returns number

    • Checks the equality of data.

      +

      Parameters

      • value: Date
      • query: Date

      Returns boolean

    • Parses data and transforms it into a date object.

      +

      Parameters

      • value: string | number | Date

      Returns Date

    • Parses data. This function is used when restoring data from database files.

      +

      Returns undefined

    • Finds data by its date.

      +

      Parameters

      • value: Date
      • query: number

      Returns boolean

    • Checks the existance of data.

      +

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is greater than (i.e. >) the query.

      +

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is greater than or equal to (i.e. >=) the query.

      +

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is equal to one of elements in query.

      +

      Parameters

      • value: unknown
      • query: unknown[]
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is less than (i.e. <) the query.

      +

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is less than or equal to (i.e. <=) the query.

      +

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Finds data by its month. (Start from 0)

      +

      Parameters

      • value: Date
      • query: number

      Returns boolean

    • Checks the equality of data. Returns true if the value doesn't match.

      +

      Parameters

      • value: Date
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is not equal to any elements in query.

      +

      Parameters

      • value: unknown
      • query: unknown[]
      • Optionaldata: unknown

      Returns boolean

    • Finds data by its year. (4-digit)

      +

      Parameters

      • value: Date
      • query: number

      Returns boolean

    • Subtracts milliseconds from date.

      +

      Parameters

      • value: Date
      • update: number

      Returns Date

    • Adds milliseconds to date.

      +

      Parameters

      • value: Date
      • update: number

      Returns Date

    • Renames a field.

      +

      Parameters

      • value: unknown
      • update: unknown
      • data: unknown

      Returns void

    • Sets the value.

      +

      Type Parameters

      • T

      Parameters

      • value: unknown
      • update: T
      • Optionaldata: unknown

      Returns T

    • Unsets the value.

      +

      Type Parameters

      • T

      Parameters

      • value: T
      • update: boolean
      • Optionaldata: unknown

      Returns T

    • Validates data.

      +

      Parameters

      • value_: unknown
      • Optionaldata: unknown

      Returns Date

    • Transforms a date object to a string.

      +

      Parameters

      • value: Date

      Returns string

    • Transforms value. This function is used when saving data to database files.

      +

      Returns undefined

    diff --git a/classes/types_enum.default.html b/classes/types_enum.default.html index fa736edc..3540c107 100644 --- a/classes/types_enum.default.html +++ b/classes/types_enum.default.html @@ -1,5 +1,5 @@ default | hexojs/warehouse

    Enum schema type.

    -

    Hierarchy (view full)

    Constructors

    Hierarchy (view full)

    Constructors

    Properties

    default name options @@ -23,25 +23,25 @@ u$unset validate value -

    Constructors

    • Parameters

      • name: string
      • Optionaloptions: Partial<{
            default?: any[] | (() => any[]);
            required: boolean;
        }> & {
            elements?: any[];
        }

      Returns default

    Properties

    default: (() => any[])
    name: string = ''
    options: {
        default?: any[] | (() => any[]);
        required: boolean;
    } & {
        elements: any[];
    }
    q$exists: ((value: unknown, query: unknown, data?: unknown) => boolean)

    Type declaration

      • (value, query, data?): boolean
      • Checks the existance of data.

        -

        Parameters

        • value: unknown
        • query: unknown
        • Optionaldata: unknown

        Returns boolean

    q$max: ((value: unknown, query: unknown, data?: unknown) => boolean)

    Type declaration

      • (value, query, data?): boolean
      • Checks whether value is less than or equal to (i.e. <=) the query.

        -

        Parameters

        • value: unknown
        • query: unknown
        • Optionaldata: unknown

        Returns boolean

    q$min: ((value: unknown, query: unknown, data?: unknown) => boolean)

    Type declaration

      • (value, query, data?): boolean
      • Checks whether value is greater than or equal to (i.e. >=) the query.

        -

        Parameters

        • value: unknown
        • query: unknown
        • Optionaldata: unknown

        Returns boolean

    Methods

    • Casts data. This function is used by getters to cast an object to document +

    Constructors

    • Parameters

      • name: string
      • Optionaloptions: Partial<{
            default?: any[] | (() => any[]);
            required: boolean;
        }> & {
            elements?: any[];
        }

      Returns default

    Properties

    default: (() => any[])
    name: string = ''
    options: {
        default?: any[] | (() => any[]);
        required: boolean;
    } & {
        elements: any[];
    }
    q$exists: ((value: unknown, query: unknown, data?: unknown) => boolean)

    Type declaration

      • (value, query, data?): boolean
      • Checks the existance of data.

        +

        Parameters

        • value: unknown
        • query: unknown
        • Optionaldata: unknown

        Returns boolean

    q$max: ((value: unknown, query: unknown, data?: unknown) => boolean)

    Type declaration

      • (value, query, data?): boolean
      • Checks whether value is less than or equal to (i.e. <=) the query.

        +

        Parameters

        • value: unknown
        • query: unknown
        • Optionaldata: unknown

        Returns boolean

    q$min: ((value: unknown, query: unknown, data?: unknown) => boolean)

    Type declaration

      • (value, query, data?): boolean
      • Checks whether value is greater than or equal to (i.e. >=) the query.

        +

        Parameters

        • value: unknown
        • query: unknown
        • Optionaldata: unknown

        Returns boolean

    Methods

    • Casts data. This function is used by getters to cast an object to document instances. If the value is null, the default value will be returned.

      -

      Parameters

      • Optionalvalue: unknown
      • Optionaldata: unknown

      Returns unknown

    • Compares data. This function is used when sorting.

      -

      Parameters

      • a: unknown
      • b: unknown

      Returns number

    • Checks the equality of data.

      -

      Parameters

      • value: any[]
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Parses data. This function is used when restoring data from database files.

      -

      Parameters

      • value: unknown

      Returns any

    • Checks the existance of data.

      -

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is greater than (i.e. >) the query.

      -

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is greater than or equal to (i.e. >=) the query.

      -

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is equal to one of elements in query.

      -

      Parameters

      • value: unknown
      • query: unknown[]
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is less than (i.e. <) the query.

      -

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is less than or equal to (i.e. <=) the query.

      -

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks the equality of data. Returns true if the value doesn't match.

      -

      Parameters

      • value: any[]
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is not equal to any elements in query.

      -

      Parameters

      • value: unknown
      • query: unknown[]
      • Optionaldata: unknown

      Returns boolean

    • Renames a field.

      -

      Parameters

      • value: unknown
      • update: unknown
      • data: unknown

      Returns void

    • Sets the value.

      -

      Type Parameters

      • T

      Parameters

      • value: unknown
      • update: T
      • Optionaldata: unknown

      Returns T

    • Unsets the value.

      -

      Type Parameters

      • T

      Parameters

      • value: T
      • update: boolean
      • Optionaldata: unknown

      Returns T

    • Validates data. The value must be one of elements set in the options.

      -

      Parameters

      • value_: unknown
      • Optionaldata: unknown

      Returns unknown

    • Transforms value. This function is used when saving data to database files.

      -

      Parameters

      • value: unknown
      • Optionaldata: unknown

      Returns any

    \ No newline at end of file +

    Parameters

    • Optionalvalue: unknown
    • Optionaldata: unknown

    Returns unknown

    • Compares data. This function is used when sorting.

      +

      Parameters

      • a: unknown
      • b: unknown

      Returns number

    • Checks the equality of data.

      +

      Parameters

      • value: any[]
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Parses data. This function is used when restoring data from database files.

      +

      Parameters

      • value: unknown

      Returns any

    • Checks the existance of data.

      +

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is greater than (i.e. >) the query.

      +

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is greater than or equal to (i.e. >=) the query.

      +

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is equal to one of elements in query.

      +

      Parameters

      • value: unknown
      • query: unknown[]
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is less than (i.e. <) the query.

      +

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is less than or equal to (i.e. <=) the query.

      +

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks the equality of data. Returns true if the value doesn't match.

      +

      Parameters

      • value: any[]
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is not equal to any elements in query.

      +

      Parameters

      • value: unknown
      • query: unknown[]
      • Optionaldata: unknown

      Returns boolean

    • Renames a field.

      +

      Parameters

      • value: unknown
      • update: unknown
      • data: unknown

      Returns void

    • Sets the value.

      +

      Type Parameters

      • T

      Parameters

      • value: unknown
      • update: T
      • Optionaldata: unknown

      Returns T

    • Unsets the value.

      +

      Type Parameters

      • T

      Parameters

      • value: T
      • update: boolean
      • Optionaldata: unknown

      Returns T

    • Validates data. The value must be one of elements set in the options.

      +

      Parameters

      • value_: unknown
      • Optionaldata: unknown

      Returns unknown

    • Transforms value. This function is used when saving data to database files.

      +

      Parameters

      • value: unknown
      • Optionaldata: unknown

      Returns any

    diff --git a/classes/types_integer.default.html b/classes/types_integer.default.html index eb888d4e..75b380c9 100644 --- a/classes/types_integer.default.html +++ b/classes/types_integer.default.html @@ -1,5 +1,5 @@ default | hexojs/warehouse

    Integer schema type.

    -

    Hierarchy (view full)

    Constructors

    Hierarchy (view full)

    Constructors

    Properties

    default name options @@ -31,31 +31,31 @@ validate value

    Constructors

    • SchemaType constructor.

      -

      Parameters

      • name: string = ''
      • Optionaloptions: {
            default?: number | (() => number);
            required?: boolean;
        }
        • Optionaldefault?: number | (() => number)
        • Optionalrequired?: boolean

      Returns default

    Properties

    default: (() => number)
    name: string = ''
    options: {
        default?: number | (() => number);
        required: boolean;
    }
    q$exists: ((value: unknown, query: unknown, data?: unknown) => boolean)

    Type declaration

      • (value, query, data?): boolean
      • Checks the existance of data.

        -

        Parameters

        • value: unknown
        • query: unknown
        • Optionaldata: unknown

        Returns boolean

    q$max: ((value: unknown, query: unknown, data?: unknown) => boolean)

    Type declaration

      • (value, query, data?): boolean
      • Checks whether value is less than or equal to (i.e. <=) the query.

        -

        Parameters

        • value: unknown
        • query: unknown
        • Optionaldata: unknown

        Returns boolean

    q$min: ((value: unknown, query: unknown, data?: unknown) => boolean)

    Type declaration

      • (value, query, data?): boolean
      • Checks whether value is greater than or equal to (i.e. >=) the query.

        -

        Parameters

        • value: unknown
        • query: unknown
        • Optionaldata: unknown

        Returns boolean

    Methods

    • Casts a integer.

      -

      Parameters

      • Optionalvalue_: unknown
      • Optionaldata: unknown

      Returns number

    • Compares data. This function is used when sorting.

      -

      Parameters

      • a: unknown
      • b: unknown

      Returns number

    • Checks the equality of data.

      -

      Parameters

      • value: number
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Parses data. This function is used when restoring data from database files.

      -

      Parameters

      • value: unknown

      Returns any

    • Checks the existance of data.

      -

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is greater than (i.e. >) the query.

      -

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is greater than or equal to (i.e. >=) the query.

      -

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is equal to one of elements in query.

      -

      Parameters

      • value: unknown
      • query: unknown[]
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is less than (i.e. <) the query.

      -

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is less than or equal to (i.e. <=) the query.

      -

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks the equality of data. Returns true if the value doesn't match.

      -

      Parameters

      • value: number
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is not equal to any elements in query.

      -

      Parameters

      • value: unknown
      • query: unknown[]
      • Optionaldata: unknown

      Returns boolean

    • Subtracts value from a number.

      -

      Parameters

      • value: number
      • update: number

      Returns number

    • Divides a number by a value.

      -

      Parameters

      • value: number
      • update: number

      Returns number

    • Adds value to a number.

      -

      Parameters

      • value: number
      • update: number

      Returns number

    • Updates a number if the value is greater than the current value.

      -

      Parameters

      • value: number
      • update: number

      Returns number

    • Updates a number if the value is less than the current value.

      -

      Parameters

      • value: number
      • update: number

      Returns number

    • Divides a number by a value and returns the remainder.

      -

      Parameters

      • value: number
      • update: number

      Returns number

    • Multiplies value to a number.

      -

      Parameters

      • value: number
      • update: number

      Returns number

    • Renames a field.

      -

      Parameters

      • value: unknown
      • update: unknown
      • data: unknown

      Returns void

    • Sets the value.

      -

      Type Parameters

      • T

      Parameters

      • value: unknown
      • update: T
      • Optionaldata: unknown

      Returns T

    • Unsets the value.

      -

      Type Parameters

      • T

      Parameters

      • value: T
      • update: boolean
      • Optionaldata: unknown

      Returns T

    • Validates an integer.

      -

      Parameters

      • Optionalvalue_: unknown
      • Optionaldata: unknown

      Returns number

    • Transforms value. This function is used when saving data to database files.

      -

      Parameters

      • value: unknown
      • Optionaldata: unknown

      Returns any

    \ No newline at end of file +

    Parameters

    • name: string = ''
    • Optionaloptions: {
          default?: number | (() => number);
          required?: boolean;
      }
      • Optionaldefault?: number | (() => number)
      • Optionalrequired?: boolean

    Returns default

    Properties

    default: (() => number)
    name: string = ''
    options: {
        default?: number | (() => number);
        required: boolean;
    }
    q$exists: ((value: unknown, query: unknown, data?: unknown) => boolean)

    Type declaration

      • (value, query, data?): boolean
      • Checks the existance of data.

        +

        Parameters

        • value: unknown
        • query: unknown
        • Optionaldata: unknown

        Returns boolean

    q$max: ((value: unknown, query: unknown, data?: unknown) => boolean)

    Type declaration

      • (value, query, data?): boolean
      • Checks whether value is less than or equal to (i.e. <=) the query.

        +

        Parameters

        • value: unknown
        • query: unknown
        • Optionaldata: unknown

        Returns boolean

    q$min: ((value: unknown, query: unknown, data?: unknown) => boolean)

    Type declaration

      • (value, query, data?): boolean
      • Checks whether value is greater than or equal to (i.e. >=) the query.

        +

        Parameters

        • value: unknown
        • query: unknown
        • Optionaldata: unknown

        Returns boolean

    Methods

    • Casts a integer.

      +

      Parameters

      • Optionalvalue_: unknown
      • Optionaldata: unknown

      Returns number

    • Compares data. This function is used when sorting.

      +

      Parameters

      • a: unknown
      • b: unknown

      Returns number

    • Checks the equality of data.

      +

      Parameters

      • value: number
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Parses data. This function is used when restoring data from database files.

      +

      Parameters

      • value: unknown

      Returns any

    • Checks the existance of data.

      +

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is greater than (i.e. >) the query.

      +

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is greater than or equal to (i.e. >=) the query.

      +

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is equal to one of elements in query.

      +

      Parameters

      • value: unknown
      • query: unknown[]
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is less than (i.e. <) the query.

      +

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is less than or equal to (i.e. <=) the query.

      +

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks the equality of data. Returns true if the value doesn't match.

      +

      Parameters

      • value: number
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is not equal to any elements in query.

      +

      Parameters

      • value: unknown
      • query: unknown[]
      • Optionaldata: unknown

      Returns boolean

    • Subtracts value from a number.

      +

      Parameters

      • value: number
      • update: number

      Returns number

    • Divides a number by a value.

      +

      Parameters

      • value: number
      • update: number

      Returns number

    • Adds value to a number.

      +

      Parameters

      • value: number
      • update: number

      Returns number

    • Updates a number if the value is greater than the current value.

      +

      Parameters

      • value: number
      • update: number

      Returns number

    • Updates a number if the value is less than the current value.

      +

      Parameters

      • value: number
      • update: number

      Returns number

    • Divides a number by a value and returns the remainder.

      +

      Parameters

      • value: number
      • update: number

      Returns number

    • Multiplies value to a number.

      +

      Parameters

      • value: number
      • update: number

      Returns number

    • Renames a field.

      +

      Parameters

      • value: unknown
      • update: unknown
      • data: unknown

      Returns void

    • Sets the value.

      +

      Type Parameters

      • T

      Parameters

      • value: unknown
      • update: T
      • Optionaldata: unknown

      Returns T

    • Unsets the value.

      +

      Type Parameters

      • T

      Parameters

      • value: T
      • update: boolean
      • Optionaldata: unknown

      Returns T

    • Validates an integer.

      +

      Parameters

      • Optionalvalue_: unknown
      • Optionaldata: unknown

      Returns number

    • Transforms value. This function is used when saving data to database files.

      +

      Parameters

      • value: unknown
      • Optionaldata: unknown

      Returns any

    diff --git a/classes/types_number.default.html b/classes/types_number.default.html index 052cf44c..ae21a5ca 100644 --- a/classes/types_number.default.html +++ b/classes/types_number.default.html @@ -1,5 +1,5 @@ default | hexojs/warehouse

    Number schema type.

    -

    Hierarchy (view full)

    Constructors

    Hierarchy (view full)

    Constructors

    Properties

    default name options @@ -31,33 +31,33 @@ validate value

    Constructors

    • SchemaType constructor.

      -

      Parameters

      • name: string = ''
      • Optionaloptions: {
            default?: number | (() => number);
            required?: boolean;
        }
        • Optionaldefault?: number | (() => number)
        • Optionalrequired?: boolean

      Returns default

    Properties

    default: (() => number)
    name: string = ''
    options: {
        default?: number | (() => number);
        required: boolean;
    }
    q$exists: ((value: unknown, query: unknown, data?: unknown) => boolean)

    Type declaration

      • (value, query, data?): boolean
      • Checks the existance of data.

        -

        Parameters

        • value: unknown
        • query: unknown
        • Optionaldata: unknown

        Returns boolean

    q$max: ((value: unknown, query: unknown, data?: unknown) => boolean)

    Type declaration

      • (value, query, data?): boolean
      • Checks whether value is less than or equal to (i.e. <=) the query.

        -

        Parameters

        • value: unknown
        • query: unknown
        • Optionaldata: unknown

        Returns boolean

    q$min: ((value: unknown, query: unknown, data?: unknown) => boolean)

    Type declaration

      • (value, query, data?): boolean
      • Checks whether value is greater than or equal to (i.e. >=) the query.

        -

        Parameters

        • value: unknown
        • query: unknown
        • Optionaldata: unknown

        Returns boolean

    Methods

    • Casts a number.

      -

      Parameters

      • value_: unknown
      • Optionaldata: unknown

      Returns number

    • Casts data. This function is used by getters to cast an object to document +

      Parameters

      • name: string = ''
      • Optionaloptions: {
            default?: number | (() => number);
            required?: boolean;
        }
        • Optionaldefault?: number | (() => number)
        • Optionalrequired?: boolean

      Returns default

    Properties

    default: (() => number)
    name: string = ''
    options: {
        default?: number | (() => number);
        required: boolean;
    }
    q$exists: ((value: unknown, query: unknown, data?: unknown) => boolean)

    Type declaration

      • (value, query, data?): boolean
      • Checks the existance of data.

        +

        Parameters

        • value: unknown
        • query: unknown
        • Optionaldata: unknown

        Returns boolean

    q$max: ((value: unknown, query: unknown, data?: unknown) => boolean)

    Type declaration

      • (value, query, data?): boolean
      • Checks whether value is less than or equal to (i.e. <=) the query.

        +

        Parameters

        • value: unknown
        • query: unknown
        • Optionaldata: unknown

        Returns boolean

    q$min: ((value: unknown, query: unknown, data?: unknown) => boolean)

    Type declaration

      • (value, query, data?): boolean
      • Checks whether value is greater than or equal to (i.e. >=) the query.

        +

        Parameters

        • value: unknown
        • query: unknown
        • Optionaldata: unknown

        Returns boolean

    Methods

    • Casts a number.

      +

      Parameters

      • value_: unknown
      • Optionaldata: unknown

      Returns number

    • Casts data. This function is used by getters to cast an object to document instances. If the value is null, the default value will be returned.

      -

      Parameters

      • Optionalvalue_: unknown
      • Optionaldata: unknown

      Returns number

    • Compares data. This function is used when sorting.

      -

      Parameters

      • a: unknown
      • b: unknown

      Returns number

    • Checks the equality of data.

      -

      Parameters

      • value: number
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Parses data. This function is used when restoring data from database files.

      -

      Parameters

      • value: unknown

      Returns any

    • Checks the existance of data.

      -

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is greater than (i.e. >) the query.

      -

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is greater than or equal to (i.e. >=) the query.

      -

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is equal to one of elements in query.

      -

      Parameters

      • value: unknown
      • query: unknown[]
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is less than (i.e. <) the query.

      -

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is less than or equal to (i.e. <=) the query.

      -

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks the equality of data. Returns true if the value doesn't match.

      -

      Parameters

      • value: number
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is not equal to any elements in query.

      -

      Parameters

      • value: unknown
      • query: unknown[]
      • Optionaldata: unknown

      Returns boolean

    • Subtracts value from a number.

      -

      Parameters

      • value: number
      • update: number

      Returns number

    • Divides a number by a value.

      -

      Parameters

      • value: number
      • update: number

      Returns number

    • Adds value to a number.

      -

      Parameters

      • value: number
      • update: number

      Returns number

    • Updates a number if the value is greater than the current value.

      -

      Parameters

      • value: number
      • update: number

      Returns number

    • Updates a number if the value is less than the current value.

      -

      Parameters

      • value: number
      • update: number

      Returns number

    • Divides a number by a value and returns the remainder.

      -

      Parameters

      • value: number
      • update: number

      Returns number

    • Multiplies value to a number.

      -

      Parameters

      • value: number
      • update: number

      Returns number

    • Renames a field.

      -

      Parameters

      • value: unknown
      • update: unknown
      • data: unknown

      Returns void

    • Sets the value.

      -

      Type Parameters

      • T

      Parameters

      • value: unknown
      • update: T
      • Optionaldata: unknown

      Returns T

    • Unsets the value.

      -

      Type Parameters

      • T

      Parameters

      • value: T
      • update: boolean
      • Optionaldata: unknown

      Returns T

    • Validates a number.

      -

      Parameters

      • Optionalvalue_: unknown
      • Optionaldata: unknown

      Returns number

    • Transforms value. This function is used when saving data to database files.

      -

      Parameters

      • value: unknown
      • Optionaldata: unknown

      Returns any

    \ No newline at end of file +

    Parameters

    • Optionalvalue_: unknown
    • Optionaldata: unknown

    Returns number

    • Compares data. This function is used when sorting.

      +

      Parameters

      • a: unknown
      • b: unknown

      Returns number

    • Checks the equality of data.

      +

      Parameters

      • value: number
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Parses data. This function is used when restoring data from database files.

      +

      Parameters

      • value: unknown

      Returns any

    • Checks the existance of data.

      +

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is greater than (i.e. >) the query.

      +

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is greater than or equal to (i.e. >=) the query.

      +

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is equal to one of elements in query.

      +

      Parameters

      • value: unknown
      • query: unknown[]
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is less than (i.e. <) the query.

      +

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is less than or equal to (i.e. <=) the query.

      +

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks the equality of data. Returns true if the value doesn't match.

      +

      Parameters

      • value: number
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is not equal to any elements in query.

      +

      Parameters

      • value: unknown
      • query: unknown[]
      • Optionaldata: unknown

      Returns boolean

    • Subtracts value from a number.

      +

      Parameters

      • value: number
      • update: number

      Returns number

    • Divides a number by a value.

      +

      Parameters

      • value: number
      • update: number

      Returns number

    • Adds value to a number.

      +

      Parameters

      • value: number
      • update: number

      Returns number

    • Updates a number if the value is greater than the current value.

      +

      Parameters

      • value: number
      • update: number

      Returns number

    • Updates a number if the value is less than the current value.

      +

      Parameters

      • value: number
      • update: number

      Returns number

    • Divides a number by a value and returns the remainder.

      +

      Parameters

      • value: number
      • update: number

      Returns number

    • Multiplies value to a number.

      +

      Parameters

      • value: number
      • update: number

      Returns number

    • Renames a field.

      +

      Parameters

      • value: unknown
      • update: unknown
      • data: unknown

      Returns void

    • Sets the value.

      +

      Type Parameters

      • T

      Parameters

      • value: unknown
      • update: T
      • Optionaldata: unknown

      Returns T

    • Unsets the value.

      +

      Type Parameters

      • T

      Parameters

      • value: T
      • update: boolean
      • Optionaldata: unknown

      Returns T

    • Validates a number.

      +

      Parameters

      • Optionalvalue_: unknown
      • Optionaldata: unknown

      Returns number

    • Transforms value. This function is used when saving data to database files.

      +

      Parameters

      • value: unknown
      • Optionaldata: unknown

      Returns any

    diff --git a/classes/types_object.default.html b/classes/types_object.default.html index b4b3b6fe..63cd1679 100644 --- a/classes/types_object.default.html +++ b/classes/types_object.default.html @@ -1,5 +1,5 @@ default | hexojs/warehouse

    Object schema type.

    -

    Hierarchy (view full)

    • default<Record<string, any>>
      • default

    Constructors

    Hierarchy (view full)

    • default<Record<string, any>>
      • default

    Constructors

    Properties

    default name options @@ -23,25 +23,25 @@ u$unset validate value -

    Constructors

    • Parameters

      • Optionalname: string
      • Optionaloptions: Partial<{
            default?: Record<string, any> | (() => Record<string, any>);
            required: boolean;
        }>

      Returns default

    Properties

    default: (() => Record<string, any>)
    name: string = ''
    options: {
        default?: Record<string, any> | (() => Record<string, any>);
        required: boolean;
    }
    q$exists: ((value: unknown, query: unknown, data?: unknown) => boolean)

    Type declaration

      • (value, query, data?): boolean
      • Checks the existance of data.

        -

        Parameters

        • value: unknown
        • query: unknown
        • Optionaldata: unknown

        Returns boolean

    q$max: ((value: unknown, query: unknown, data?: unknown) => boolean)

    Type declaration

      • (value, query, data?): boolean
      • Checks whether value is less than or equal to (i.e. <=) the query.

        -

        Parameters

        • value: unknown
        • query: unknown
        • Optionaldata: unknown

        Returns boolean

    q$min: ((value: unknown, query: unknown, data?: unknown) => boolean)

    Type declaration

      • (value, query, data?): boolean
      • Checks whether value is greater than or equal to (i.e. >=) the query.

        -

        Parameters

        • value: unknown
        • query: unknown
        • Optionaldata: unknown

        Returns boolean

    Methods

    • Casts data. This function is used by getters to cast an object to document +

    Constructors

    • Parameters

      • Optionalname: string
      • Optionaloptions: Partial<{
            default?: Record<string, any> | (() => Record<string, any>);
            required: boolean;
        }>

      Returns default

    Properties

    default: (() => Record<string, any>)
    name: string = ''
    options: {
        default?: Record<string, any> | (() => Record<string, any>);
        required: boolean;
    }
    q$exists: ((value: unknown, query: unknown, data?: unknown) => boolean)

    Type declaration

      • (value, query, data?): boolean
      • Checks the existance of data.

        +

        Parameters

        • value: unknown
        • query: unknown
        • Optionaldata: unknown

        Returns boolean

    q$max: ((value: unknown, query: unknown, data?: unknown) => boolean)

    Type declaration

      • (value, query, data?): boolean
      • Checks whether value is less than or equal to (i.e. <=) the query.

        +

        Parameters

        • value: unknown
        • query: unknown
        • Optionaldata: unknown

        Returns boolean

    q$min: ((value: unknown, query: unknown, data?: unknown) => boolean)

    Type declaration

      • (value, query, data?): boolean
      • Checks whether value is greater than or equal to (i.e. >=) the query.

        +

        Parameters

        • value: unknown
        • query: unknown
        • Optionaldata: unknown

        Returns boolean

    Methods

    • Casts data. This function is used by getters to cast an object to document instances. If the value is null, the default value will be returned.

      -

      Parameters

      • Optionalvalue: unknown
      • Optionaldata: unknown

      Returns unknown

    • Compares data. This function is used when sorting.

      -

      Parameters

      • a: unknown
      • b: unknown

      Returns number

    • Checks the equality of data.

      -

      Parameters

      • value: Record<string, any>
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Parses data. This function is used when restoring data from database files.

      -

      Parameters

      • value: unknown

      Returns any

    • Checks the existance of data.

      -

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is greater than (i.e. >) the query.

      -

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is greater than or equal to (i.e. >=) the query.

      -

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is equal to one of elements in query.

      -

      Parameters

      • value: unknown
      • query: unknown[]
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is less than (i.e. <) the query.

      -

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is less than or equal to (i.e. <=) the query.

      -

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks the equality of data. Returns true if the value doesn't match.

      -

      Parameters

      • value: Record<string, any>
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is not equal to any elements in query.

      -

      Parameters

      • value: unknown
      • query: unknown[]
      • Optionaldata: unknown

      Returns boolean

    • Renames a field.

      -

      Parameters

      • value: unknown
      • update: unknown
      • data: unknown

      Returns void

    • Sets the value.

      -

      Type Parameters

      • T

      Parameters

      • value: unknown
      • update: T
      • Optionaldata: unknown

      Returns T

    • Unsets the value.

      -

      Type Parameters

      • T

      Parameters

      • value: T
      • update: boolean
      • Optionaldata: unknown

      Returns T

    • Validates data. This function is used by setters.

      -

      Parameters

      • value: unknown
      • Optionaldata: unknown

      Returns unknown

    • Transforms value. This function is used when saving data to database files.

      -

      Parameters

      • value: unknown
      • Optionaldata: unknown

      Returns any

    \ No newline at end of file +

    Parameters

    • Optionalvalue: unknown
    • Optionaldata: unknown

    Returns unknown

    • Compares data. This function is used when sorting.

      +

      Parameters

      • a: unknown
      • b: unknown

      Returns number

    • Checks the equality of data.

      +

      Parameters

      • value: Record<string, any>
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Parses data. This function is used when restoring data from database files.

      +

      Parameters

      • value: unknown

      Returns any

    • Checks the existance of data.

      +

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is greater than (i.e. >) the query.

      +

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is greater than or equal to (i.e. >=) the query.

      +

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is equal to one of elements in query.

      +

      Parameters

      • value: unknown
      • query: unknown[]
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is less than (i.e. <) the query.

      +

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is less than or equal to (i.e. <=) the query.

      +

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks the equality of data. Returns true if the value doesn't match.

      +

      Parameters

      • value: Record<string, any>
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is not equal to any elements in query.

      +

      Parameters

      • value: unknown
      • query: unknown[]
      • Optionaldata: unknown

      Returns boolean

    • Renames a field.

      +

      Parameters

      • value: unknown
      • update: unknown
      • data: unknown

      Returns void

    • Sets the value.

      +

      Type Parameters

      • T

      Parameters

      • value: unknown
      • update: T
      • Optionaldata: unknown

      Returns T

    • Unsets the value.

      +

      Type Parameters

      • T

      Parameters

      • value: T
      • update: boolean
      • Optionaldata: unknown

      Returns T

    • Validates data. This function is used by setters.

      +

      Parameters

      • value: unknown
      • Optionaldata: unknown

      Returns unknown

    • Transforms value. This function is used when saving data to database files.

      +

      Parameters

      • value: unknown
      • Optionaldata: unknown

      Returns any

    diff --git a/classes/types_string.default.html b/classes/types_string.default.html index 9f984985..382d2412 100644 --- a/classes/types_string.default.html +++ b/classes/types_string.default.html @@ -1,5 +1,5 @@ default | hexojs/warehouse

    String schema type.

    -

    Hierarchy (view full)

    Constructors

    Hierarchy (view full)

    Constructors

    Properties

    default name options @@ -25,27 +25,27 @@ validate value

    Constructors

    • SchemaType constructor.

      -

      Parameters

      • name: string = ''
      • Optionaloptions: {
            default?: string | (() => string);
            required?: boolean;
        }
        • Optionaldefault?: string | (() => string)
        • Optionalrequired?: boolean

      Returns default

    Properties

    default: (() => string)
    name: string = ''
    options: {
        default?: string | (() => string);
        required: boolean;
    }
    q$exists: ((value: unknown, query: unknown, data?: unknown) => boolean)

    Type declaration

      • (value, query, data?): boolean
      • Checks the existance of data.

        -

        Parameters

        • value: unknown
        • query: unknown
        • Optionaldata: unknown

        Returns boolean

    q$max: ((value: unknown, query: unknown, data?: unknown) => boolean)

    Type declaration

      • (value, query, data?): boolean
      • Checks whether value is less than or equal to (i.e. <=) the query.

        -

        Parameters

        • value: unknown
        • query: unknown
        • Optionaldata: unknown

        Returns boolean

    q$min: ((value: unknown, query: unknown, data?: unknown) => boolean)

    Type declaration

      • (value, query, data?): boolean
      • Checks whether value is greater than or equal to (i.e. >=) the query.

        -

        Parameters

        • value: unknown
        • query: unknown
        • Optionaldata: unknown

        Returns boolean

    Methods

    • Casts a string.

      -

      Parameters

      • value_: {
            toString(): string;
        }
      • Optionaldata: unknown

      Returns string

    • Casts data. This function is used by getters to cast an object to document +

      Parameters

      • name: string = ''
      • Optionaloptions: {
            default?: string | (() => string);
            required?: boolean;
        }
        • Optionaldefault?: string | (() => string)
        • Optionalrequired?: boolean

      Returns default

    Properties

    default: (() => string)
    name: string = ''
    options: {
        default?: string | (() => string);
        required: boolean;
    }
    q$exists: ((value: unknown, query: unknown, data?: unknown) => boolean)

    Type declaration

      • (value, query, data?): boolean
      • Checks the existance of data.

        +

        Parameters

        • value: unknown
        • query: unknown
        • Optionaldata: unknown

        Returns boolean

    q$max: ((value: unknown, query: unknown, data?: unknown) => boolean)

    Type declaration

      • (value, query, data?): boolean
      • Checks whether value is less than or equal to (i.e. <=) the query.

        +

        Parameters

        • value: unknown
        • query: unknown
        • Optionaldata: unknown

        Returns boolean

    q$min: ((value: unknown, query: unknown, data?: unknown) => boolean)

    Type declaration

      • (value, query, data?): boolean
      • Checks whether value is greater than or equal to (i.e. >=) the query.

        +

        Parameters

        • value: unknown
        • query: unknown
        • Optionaldata: unknown

        Returns boolean

    Methods

    • Casts a string.

      +

      Parameters

      • value_: {
            toString(): string;
        }
      • Optionaldata: unknown

      Returns string

    • Casts data. This function is used by getters to cast an object to document instances. If the value is null, the default value will be returned.

      -

      Parameters

      • Optionalvalue_: unknown
      • Optionaldata: unknown

      Returns string

    • Compares data. This function is used when sorting.

      -

      Parameters

      • a: unknown
      • b: unknown

      Returns number

    • Checks the equality of data.

      -

      Parameters

      • value: string
      • query: string | RegExp
      • Optionaldata: unknown

      Returns boolean

    • Parses data. This function is used when restoring data from database files.

      -

      Parameters

      • value: unknown

      Returns any

    • Checks the existance of data.

      -

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is greater than (i.e. >) the query.

      -

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is greater than or equal to (i.e. >=) the query.

      -

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether a string is equal to one of elements in query.

      -

      Parameters

      • value: string
      • query: string[] | RegExp[]
      • Optionaldata: unknown

      Returns boolean

    • Checks length of a string.

      -

      Parameters

      • value: string
      • query: number

      Returns boolean

    • Checks whether value is less than (i.e. <) the query.

      -

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is less than or equal to (i.e. <=) the query.

      -

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks the equality of data. Returns true if the value doesn't match.

      -

      Parameters

      • value: string
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether a string is not equal to any elements in query.

      -

      Parameters

      • value: string
      • query: string[] | RegExp[]
      • Optionaldata: unknown

      Returns boolean

    • Renames a field.

      -

      Parameters

      • value: unknown
      • update: unknown
      • data: unknown

      Returns void

    • Sets the value.

      -

      Type Parameters

      • T

      Parameters

      • value: unknown
      • update: T
      • Optionaldata: unknown

      Returns T

    • Unsets the value.

      -

      Type Parameters

      • T

      Parameters

      • value: T
      • update: boolean
      • Optionaldata: unknown

      Returns T

    • Validates a string.

      -

      Parameters

      • Optionalvalue_: unknown
      • Optionaldata: unknown

      Returns string

    • Transforms value. This function is used when saving data to database files.

      -

      Parameters

      • value: unknown
      • Optionaldata: unknown

      Returns any

    \ No newline at end of file +

    Parameters

    • Optionalvalue_: unknown
    • Optionaldata: unknown

    Returns string

    • Compares data. This function is used when sorting.

      +

      Parameters

      • a: unknown
      • b: unknown

      Returns number

    • Checks the equality of data.

      +

      Parameters

      • value: string
      • query: string | RegExp
      • Optionaldata: unknown

      Returns boolean

    • Parses data. This function is used when restoring data from database files.

      +

      Parameters

      • value: unknown

      Returns any

    • Checks the existance of data.

      +

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is greater than (i.e. >) the query.

      +

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is greater than or equal to (i.e. >=) the query.

      +

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether a string is equal to one of elements in query.

      +

      Parameters

      • value: string
      • query: string[] | RegExp[]
      • Optionaldata: unknown

      Returns boolean

    • Checks length of a string.

      +

      Parameters

      • value: string
      • query: number

      Returns boolean

    • Checks whether value is less than (i.e. <) the query.

      +

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is less than or equal to (i.e. <=) the query.

      +

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks the equality of data. Returns true if the value doesn't match.

      +

      Parameters

      • value: string
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether a string is not equal to any elements in query.

      +

      Parameters

      • value: string
      • query: string[] | RegExp[]
      • Optionaldata: unknown

      Returns boolean

    • Renames a field.

      +

      Parameters

      • value: unknown
      • update: unknown
      • data: unknown

      Returns void

    • Sets the value.

      +

      Type Parameters

      • T

      Parameters

      • value: unknown
      • update: T
      • Optionaldata: unknown

      Returns T

    • Unsets the value.

      +

      Type Parameters

      • T

      Parameters

      • value: T
      • update: boolean
      • Optionaldata: unknown

      Returns T

    • Validates a string.

      +

      Parameters

      • Optionalvalue_: unknown
      • Optionaldata: unknown

      Returns string

    • Transforms value. This function is used when saving data to database files.

      +

      Parameters

      • value: unknown
      • Optionaldata: unknown

      Returns any

    diff --git a/classes/types_virtual.default.html b/classes/types_virtual.default.html index 6d491ea9..ac7b9514 100644 --- a/classes/types_virtual.default.html +++ b/classes/types_virtual.default.html @@ -1,5 +1,5 @@ default | hexojs/warehouse

    Virtual schema type.

    -

    Type Parameters

    • T = any

    Hierarchy (view full)

    Constructors

    Type Parameters

    • T = any

    Hierarchy (view full)

    Constructors

    Properties

    default getter name @@ -28,26 +28,26 @@ validate value

    Constructors

    • SchemaType constructor.

      -

      Type Parameters

      • T = any

      Parameters

      • name: string = ''
      • Optionaloptions: {
            default?: any;
            required?: boolean;
        }
        • Optionaldefault?: any
        • Optionalrequired?: boolean

      Returns default<T>

    Properties

    default: (() => any)
    getter: ((this: T) => any)
    name: string = ''
    options: {
        default?: any;
        required: boolean;
    }
    q$exists: ((value: unknown, query: unknown, data?: unknown) => boolean)

    Type declaration

      • (value, query, data?): boolean
      • Checks the existance of data.

        -

        Parameters

        • value: unknown
        • query: unknown
        • Optionaldata: unknown

        Returns boolean

    q$max: ((value: unknown, query: unknown, data?: unknown) => boolean)

    Type declaration

      • (value, query, data?): boolean
      • Checks whether value is less than or equal to (i.e. <=) the query.

        -

        Parameters

        • value: unknown
        • query: unknown
        • Optionaldata: unknown

        Returns boolean

    q$min: ((value: unknown, query: unknown, data?: unknown) => boolean)

    Type declaration

      • (value, query, data?): boolean
      • Checks whether value is greater than or equal to (i.e. >=) the query.

        -

        Parameters

        • value: unknown
        • query: unknown
        • Optionaldata: unknown

        Returns boolean

    setter: ((value: any) => void)

    Methods

    • Compares data. This function is used when sorting.

      -

      Parameters

      • a: unknown
      • b: unknown

      Returns number

    • Checks the equality of data.

      -

      Parameters

      • value: any
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Parses data. This function is used when restoring data from database files.

      -

      Parameters

      • value: unknown

      Returns any

    • Checks the existance of data.

      -

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is greater than (i.e. >) the query.

      -

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is greater than or equal to (i.e. >=) the query.

      -

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is equal to one of elements in query.

      -

      Parameters

      • value: unknown
      • query: unknown[]
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is less than (i.e. <) the query.

      -

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is less than or equal to (i.e. <=) the query.

      -

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks the equality of data. Returns true if the value doesn't match.

      -

      Parameters

      • value: any
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is not equal to any elements in query.

      -

      Parameters

      • value: unknown
      • query: unknown[]
      • Optionaldata: unknown

      Returns boolean

    • Add a setter.

      -

      Parameters

      • fn: ((this: T, value: any) => void)
          • (this, value): void
          • Parameters

            • this: T
            • value: any

            Returns void

      Returns default<T>

    • Renames a field.

      -

      Parameters

      • value: unknown
      • update: unknown
      • data: unknown

      Returns void

    • Sets the value.

      -

      Type Parameters

      • T

      Parameters

      • value: unknown
      • update: T
      • Optionaldata: unknown

      Returns T

    • Unsets the value.

      -

      Type Parameters

      • T

      Parameters

      • value: T
      • update: boolean
      • Optionaldata: unknown

      Returns T

    • Transforms value. This function is used when saving data to database files.

      -

      Parameters

      • value: unknown
      • Optionaldata: unknown

      Returns any

    \ No newline at end of file +

    Type Parameters

    • T = any

    Parameters

    • name: string = ''
    • Optionaloptions: {
          default?: any;
          required?: boolean;
      }
      • Optionaldefault?: any
      • Optionalrequired?: boolean

    Returns default<T>

    Properties

    default: (() => any)
    getter: ((this: T) => any)
    name: string = ''
    options: {
        default?: any;
        required: boolean;
    }
    q$exists: ((value: unknown, query: unknown, data?: unknown) => boolean)

    Type declaration

      • (value, query, data?): boolean
      • Checks the existance of data.

        +

        Parameters

        • value: unknown
        • query: unknown
        • Optionaldata: unknown

        Returns boolean

    q$max: ((value: unknown, query: unknown, data?: unknown) => boolean)

    Type declaration

      • (value, query, data?): boolean
      • Checks whether value is less than or equal to (i.e. <=) the query.

        +

        Parameters

        • value: unknown
        • query: unknown
        • Optionaldata: unknown

        Returns boolean

    q$min: ((value: unknown, query: unknown, data?: unknown) => boolean)

    Type declaration

      • (value, query, data?): boolean
      • Checks whether value is greater than or equal to (i.e. >=) the query.

        +

        Parameters

        • value: unknown
        • query: unknown
        • Optionaldata: unknown

        Returns boolean

    setter: ((value: any) => void)

    Methods

    • Compares data. This function is used when sorting.

      +

      Parameters

      • a: unknown
      • b: unknown

      Returns number

    • Checks the equality of data.

      +

      Parameters

      • value: any
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Parses data. This function is used when restoring data from database files.

      +

      Parameters

      • value: unknown

      Returns any

    • Checks the existance of data.

      +

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is greater than (i.e. >) the query.

      +

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is greater than or equal to (i.e. >=) the query.

      +

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is equal to one of elements in query.

      +

      Parameters

      • value: unknown
      • query: unknown[]
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is less than (i.e. <) the query.

      +

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is less than or equal to (i.e. <=) the query.

      +

      Parameters

      • value: unknown
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks the equality of data. Returns true if the value doesn't match.

      +

      Parameters

      • value: any
      • query: unknown
      • Optionaldata: unknown

      Returns boolean

    • Checks whether value is not equal to any elements in query.

      +

      Parameters

      • value: unknown
      • query: unknown[]
      • Optionaldata: unknown

      Returns boolean

    • Add a setter.

      +

      Parameters

      • fn: ((this: T, value: any) => void)
          • (this, value): void
          • Parameters

            • this: T
            • value: any

            Returns void

      Returns default<T>

    • Renames a field.

      +

      Parameters

      • value: unknown
      • update: unknown
      • data: unknown

      Returns void

    • Sets the value.

      +

      Type Parameters

      • T

      Parameters

      • value: unknown
      • update: T
      • Optionaldata: unknown

      Returns T

    • Unsets the value.

      +

      Type Parameters

      • T

      Parameters

      • value: T
      • update: boolean
      • Optionaldata: unknown

      Returns T

    • Transforms value. This function is used when saving data to database files.

      +

      Parameters

      • value: unknown
      • Optionaldata: unknown

      Returns any

    diff --git a/functions/lib_jsonstream.parse.html b/functions/lib_jsonstream.parse.html index 52a7f6b0..c0134dcb 100644 --- a/functions/lib_jsonstream.parse.html +++ b/functions/lib_jsonstream.parse.html @@ -1 +1 @@ -parse | hexojs/warehouse
    \ No newline at end of file +parse | hexojs/warehouse
    diff --git a/functions/util.arr2obj.html b/functions/util.arr2obj.html index 664c5a6b..fc87d456 100644 --- a/functions/util.arr2obj.html +++ b/functions/util.arr2obj.html @@ -1 +1 @@ -arr2obj | hexojs/warehouse
    • Parameters

      • arr: any
      • value: any

      Returns {}

      \ No newline at end of file +arr2obj | hexojs/warehouse
      • Parameters

        • arr: any
        • value: any

        Returns {}

        diff --git a/functions/util.delProp.html b/functions/util.delProp.html index 06f4e986..7998f6c9 100644 --- a/functions/util.delProp.html +++ b/functions/util.delProp.html @@ -1 +1 @@ -delProp | hexojs/warehouse
        • Parameters

          • obj: any
          • key: any

          Returns void

        \ No newline at end of file +delProp | hexojs/warehouse
        • Parameters

          • obj: any
          • key: any

          Returns void

        diff --git a/functions/util.getProp.html b/functions/util.getProp.html index 80a33d06..8b3018a2 100644 --- a/functions/util.getProp.html +++ b/functions/util.getProp.html @@ -1 +1 @@ -getProp | hexojs/warehouse
        • Parameters

          • obj: any
          • key: any

          Returns any

        \ No newline at end of file +getProp | hexojs/warehouse
        • Parameters

          • obj: any
          • key: any

          Returns any

        diff --git a/functions/util.parseArgs.html b/functions/util.parseArgs.html index 8250908a..6fbcad07 100644 --- a/functions/util.parseArgs.html +++ b/functions/util.parseArgs.html @@ -1 +1 @@ -parseArgs | hexojs/warehouse
        • Parameters

          • orderby: string | object
          • Optionalorder: string | number | object

          Returns any

        \ No newline at end of file +parseArgs | hexojs/warehouse
        • Parameters

          • orderby: string | object
          • Optionalorder: string | number | object

          Returns any

        diff --git a/functions/util.reverse.html b/functions/util.reverse.html index 53edd4d7..9aeaa582 100644 --- a/functions/util.reverse.html +++ b/functions/util.reverse.html @@ -1 +1 @@ -reverse | hexojs/warehouse
        • Parameters

          • arr: any

          Returns any[]

        \ No newline at end of file +reverse | hexojs/warehouse
        • Parameters

          • arr: any

          Returns any[]

        diff --git a/functions/util.setGetter.html b/functions/util.setGetter.html index 9b1c3449..de2aa588 100644 --- a/functions/util.setGetter.html +++ b/functions/util.setGetter.html @@ -1 +1 @@ -setGetter | hexojs/warehouse
        • Parameters

          • obj: any
          • key: any
          • fn: any

          Returns void

        \ No newline at end of file +setGetter | hexojs/warehouse
        • Parameters

          • obj: any
          • key: any
          • fn: any

          Returns void

        diff --git a/functions/util.setProp.html b/functions/util.setProp.html index 7b78cce9..e1543330 100644 --- a/functions/util.setProp.html +++ b/functions/util.setProp.html @@ -1 +1 @@ -setProp | hexojs/warehouse
        • Parameters

          • obj: any
          • key: any
          • value: any

          Returns void

        \ No newline at end of file +setProp | hexojs/warehouse
        • Parameters

          • obj: any
          • key: any
          • value: any

          Returns void

        diff --git a/functions/util.shuffle.html b/functions/util.shuffle.html index fca8215d..904935d1 100644 --- a/functions/util.shuffle.html +++ b/functions/util.shuffle.html @@ -1 +1 @@ -shuffle | hexojs/warehouse
        • Parameters

          • array: any

          Returns any[]

        \ No newline at end of file +shuffle | hexojs/warehouse
        • Parameters

          • array: any

          Returns any[]

        diff --git a/hierarchy.html b/hierarchy.html index 0d01319a..f2cb1d27 100644 --- a/hierarchy.html +++ b/hierarchy.html @@ -1 +1 @@ -hexojs/warehouse
        \ No newline at end of file +hexojs/warehouse
        diff --git a/index.html b/index.html index 4c99792a..9b4a6d28 100644 --- a/index.html +++ b/index.html @@ -22,9 +22,9 @@
        $ npm test
         
        -
        \ No newline at end of file +
        diff --git a/interfaces/types-1.AddSchemaTypeLoopOptions.html b/interfaces/types-1.AddSchemaTypeLoopOptions.html index 21ffd045..fb6ca68a 100644 --- a/interfaces/types-1.AddSchemaTypeLoopOptions.html +++ b/interfaces/types-1.AddSchemaTypeLoopOptions.html @@ -1 +1 @@ -AddSchemaTypeLoopOptions | hexojs/warehouse

        Interface AddSchemaTypeLoopOptions

        Indexable

        \ No newline at end of file +AddSchemaTypeLoopOptions | hexojs/warehouse

        Interface AddSchemaTypeLoopOptions

        Indexable

        diff --git a/interfaces/types-1.Options.html b/interfaces/types-1.Options.html index 96040054..8aa36fb6 100644 --- a/interfaces/types-1.Options.html +++ b/interfaces/types-1.Options.html @@ -1,4 +1,4 @@ -Options | hexojs/warehouse
        interface Options {
            lean?: boolean;
            limit?: number;
            skip?: number;
            [key: PropertyKey]: any;
        }

        Indexable

        • [key: PropertyKey]: any

        Properties

        lean? +Options | hexojs/warehouse
        interface Options {
            lean?: boolean;
            limit?: number;
            skip?: number;
            [key: PropertyKey]: any;
        }

        Indexable

        • [key: PropertyKey]: any

        Properties

        Properties

        lean?: boolean
        limit?: number
        skip?: number
        \ No newline at end of file +

        Properties

        lean?: boolean
        limit?: number
        skip?: number
        diff --git a/media/scripts/database.ts b/media/scripts/database.ts deleted file mode 100644 index a062ea5e..00000000 --- a/media/scripts/database.ts +++ /dev/null @@ -1,121 +0,0 @@ -import chai from 'chai'; -const should = chai.should(); // eslint-disable-line -import path from 'path'; -import Promise from 'bluebird'; -import sinon from 'sinon'; -import Database from '../../dist/database'; -import Model from '../../dist/model'; -import fs from 'fs'; -const promisifyFs = Promise.promisifyAll(fs); - -const DB_PATH = path.join(path.dirname(__dirname), 'fixtures', 'db.json'); -const DB_VERSION = 1; - -describe('Database', () => { - const Schema = Database.Schema; - const db = new Database({path: DB_PATH, version: DB_VERSION}); - - const TestModel = db.model('Test', new Schema({ - _id: {type: String, required: true} - })); - - before(() => TestModel.insert([ - {_id: 'A'}, - {_id: 'B'}, - {_id: 'C'} - ])); - - it('model() - get', () => { - const Test = db.model('Test'); - Test.data.should.eql(TestModel.data); - }); - - it('model() - create', () => { - const Post = db.model('Post'); - Post.should.be.an.instanceOf(Model); - db._models.Post.should.exist; - Post.destroy(); - }); - - it('load()', () => { - const db = new Database({path: DB_PATH}); - - return db.load().then(() => { - const Test = db.model('Test'); - - Test.toArray().should.eql([ - Test.new({_id: 'A'}), - Test.new({_id: 'B'}), - Test.new({_id: 'C'}) - ]); - }); - }); - - it('load() - upgrade', () => { - const onUpgrade = sinon.spy((oldVersion, newVersion) => { - oldVersion.should.eql(DB_VERSION); - newVersion.should.eql(2); - }); - - const db = new Database({ - path: DB_PATH, - version: 2, - onUpgrade - }); - - return db.load().then(() => { - onUpgrade.calledOnce.should.be.true; - }); - }); - - it('load() - downgrade', () => { - const onDowngrade = sinon.spy((oldVersion, newVersion) => { - oldVersion.should.eql(DB_VERSION); - newVersion.should.eql(0); - }); - - const db = new Database({ - path: DB_PATH, - version: 0, - onDowngrade - }); - - return db.load().then(() => { - onDowngrade.calledOnce.should.be.true; - }); - }); - - it('save()', () => db.save().then(() => promisifyFs.readFileAsync(DB_PATH)).then(data => { - // TODO: fix - // @ts-ignore - const json = JSON.parse(data); - - json.meta.should.eql({ - version: DB_VERSION, - warehouse: Database.version - }); - - json.models.should.eql({ - Test: [ - {_id: 'A'}, - {_id: 'B'}, - {_id: 'C'} - ] - }); - })); - - it('toJSON()', () => { - const db = new Database({ - path: DB_PATH, - version: 0 - }); - - return db.load().then(() => { - const model = db.model('Test'); - const json = db.toJSON(); - json.meta.version.should.eql(0); - (json.models as any).Test.should.eql(model); - console.log(db.toJSON()); - }); - }); -}); diff --git a/media/scripts/document.ts b/media/scripts/document.ts deleted file mode 100644 index 565215ff..00000000 --- a/media/scripts/document.ts +++ /dev/null @@ -1,131 +0,0 @@ -import chai from 'chai'; -const should = chai.should(); // eslint-disable-line -import Database from '../../dist/database'; -import Document from '../../dist/document'; -import type Model from '../../dist/model'; - -interface UserType { - name?: string; - age?: number; - comments?: string; -} - -interface CommentType { - content?: string; - author?: string; -} - -describe('Document', () => { - const db = new Database(); - const Schema = Database.Schema; - - const User: Model = db.model('User', { - name: String, - age: Number, - comments: [{type: Schema.Types.CUID, ref: 'Comment'}] - }); - - const Comment: Model = db.model('Comment', { - content: String, - author: {type: Schema.Types.CUID, ref: 'User'} - }); - - it('constructor', () => { - const doc = User.new({ - name: 'John', - age: 20 - }); - - doc.should.be.an.instanceOf(Document); - doc.name.should.eql('John'); - doc.age.should.eql(20); - }); - - it('constructor - no arguments', () => { - const doc = User.new(); - - doc.should.be.an.instanceOf(Document); - }); - - it('save() - insert', () => { - const doc = User.new({}); - - return doc.save().then(item => { - User.findById(doc._id as string | number).should.exist; - return User.removeById(item._id); - }); - }); - - it('save() - replace', () => User.insert({}).then(doc => { - doc.name = 'A'; - return doc.save(); - }).then(doc => { - doc.name.should.eql('A'); - return User.removeById(doc._id); - })); - - it('update()', () => User.insert({}).then(doc => doc.update({name: 'A'})).then(doc => { - doc.name.should.eql('A'); - return User.removeById(doc._id); - })); - - it('replace()', () => User.insert({}).then(doc => doc.replace({name: 'A'})).then(doc => { - doc.name.should.eql('A'); - return User.removeById(doc._id); - })); - - it('remove()', () => User.insert({}).then(doc => doc.remove()).then(doc => { - should.not.exist(User.findById(doc._id)); - })); - - it('toObject()', () => { - const doc = User.new({}); - doc.toObject().should.not.be.instanceOf(User.Document); - }); - - it('toObject() - don\'t deep clone getters', () => { - const db = new Database(); - let User; - - const userSchema = new Schema({ - name: String, - age: Number - }); - - userSchema.virtual('users').get(() => User.find({})); - - User = db.model('User', userSchema); - - return User.insert({}).then(data => User.findById(data._id)).then(data => { - data.toObject().should.be.ok; - }); - }); - - it('toString()', () => { - const doc = User.new({}); - doc.toString().should.eql(JSON.stringify(doc)); - }); - - it('populate() - object', () => User.insert({}).then(user => { - const comment = Comment.new({ - author: user._id - }); - - comment.populate('author').author.should.eql(user); - return user; - }).then(user => User.removeById(user._id))); - - it('populate() - array', () => Comment.insert([ - {content: 'foo'}, - {content: 'bar'}, - {content: 'baz'}, - {content: 'ha'} - ]).then(comments => { - const user = User.new({ - comments: comments.map(comment => comment._id) - }); - - user.populate('comments').comments.toArray().should.eql(comments); - return comments; - }).map(comment => Comment.removeById(comment._id))); -}); diff --git a/media/scripts/model.ts b/media/scripts/model.ts deleted file mode 100644 index 3d9b59d7..00000000 --- a/media/scripts/model.ts +++ /dev/null @@ -1,1350 +0,0 @@ -import chai from 'chai'; -const should = chai.should(); // eslint-disable-line -import chaiAsPromised from 'chai-as-promised'; -chai.use(chaiAsPromised ); // eslint-disable-line - -import lodash from 'lodash'; -const { sortBy } = lodash; -import Promise from 'bluebird'; -import sinon from 'sinon'; -import { nanoid } from 'nanoid'; -import Database from '../../dist/database'; -import type Query from '../../dist/query'; -import type Document from '../../dist/document'; -import type Model from '../../dist/model'; - -interface UserType { - name?: { - first: string; - last: string; - } - email?: string; - age?: number; - posts?: string[]; -} - -interface PostType { - title?: string; - content?: string; - user_id?: string; - created?: Date; -} - -describe('Model', () => { - - const Schema = Database.Schema; - const SchemaType = Database.SchemaType; - - const db = new Database(); - - const userSchema = new Schema<{ - name: { - first: string; - last: string; - } - email: string; - age: number; - posts: string[]; - }>({ - name: { - first: String, - last: String - }, - email: String, - age: Number, - posts: [{type: Schema.Types.CUID, ref: 'Post'}] - }); - - userSchema.virtual('name.full').get(function() { - return `${this.name.first} ${this.name.last}`; - }); - - const postSchema = new Schema({ - title: String, - content: String, - user_id: {type: Schema.Types.CUID, ref: 'User'}, - created: Date - }); - - const User: Model = db.model('User', userSchema); - const Post: Model = db.model('Post', postSchema); - - it('new()', () => { - const user = User.new({ - name: {first: 'John', last: 'Doe'}, - email: 'abc@example.com', - age: 20 - }); - - user._id!.should.exist; - user.name.first.should.eql('John'); - user.name.last.should.eql('Doe'); - user.name.full.should.eql('John Doe'); - user.email.should.eql('abc@example.com'); - user.age.should.eql(20); - user.posts.should.eql([]); - }); - - it('findById()', () => User.insert({ - name: {first: 'John', last: 'Doe'}, - email: 'abc@example.com', - age: 20 - }).then(data => { - User.findById(data._id).should.eql(data); - return data; - }).then(data => User.removeById(data._id))); - - it('findById() - lean', () => User.insert({ - name: {first: 'John', last: 'Doe'}, - email: 'abc@example.com', - age: 20 - }).then(data => { - User.findById(data._id, {lean: true}).name.should.not.ownProperty('full'); - return data; - }).then(data => User.removeById(data._id))); - - it('insert()', () => { - const listener = sinon.spy(data => { - User.findById(data._id).should.exist; - }); - - User.once('insert', listener); - - return User.insert({ - name: {first: 'John', last: 'Doe'}, - email: 'abc@example.com', - age: 20 - }).then(data => { - User.findById(data._id).should.exist; - User.should.to.have.length(1); - listener.calledOnce.should.be.true; - return data; - }).then(data => User.removeById(data._id)); - }); - - it('insert() - no id', () => { - const doc = User.new(); - delete doc._id; - - return (User.insert(doc) as any).should.eventually.be.rejected; - }); - - it('insert() - already existed', () => { - let user; - - return (User.insert({}).then(data => { - user = data; - return User.insert(data); - }).finally(() => User.removeById(user._id)) as any).should.eventually.be.rejected; - }); - - it('insert() - hook', () => { - const db = new Database(); - const testSchema = new Schema(); - let Test; - - const preHook = sinon.spy(data => { - should.not.exist(Test.findById(data._id)); - data.foo.should.eql('bar'); - }); - - const postHook = sinon.spy(data => { - Test.findById(data._id).should.exist; - data.foo.should.eql('bar'); - }); - - testSchema.pre('save', preHook); - testSchema.post('save', postHook); - - Test = db.model('Test', testSchema); - - return Test.insert({foo: 'bar'}).then(() => { - preHook.calledOnce.should.be.true; - postHook.calledOnce.should.be.true; - }); - }); - - it('insert() - array', () => User.insert([ - { - name: {first: 'John', last: 'Doe'}, - email: 'abc@example.com', - age: 20 - }, - { - name: {first: 'Andy', last: 'Baker'}, - email: 'andy@example.com', - age: 30 - } - ]).then(data => { - data.length = 2; - return data; - }).map(item => User.removeById(item._id))); - - it('insert() - sync problem', () => { - const db = new Database(); - const testSchema = new Schema(); - let Test; - - testSchema.pre('save', data => { - const item = Test.findOne({id: data.id}); - if (item) throw new Error(`ID "${data.id}" has been used.`); - }); - - Test = db.model('Test', testSchema); - - return Promise.all([ - Test.insert({id: 1}), - Test.insert({id: 1}) - // @ts-ignore - ]).should.eventually.be.rejected; - }); - - it('save() - insert', () => User.save({ - name: {first: 'John', last: 'Doe'}, - email: 'abc@example.com', - age: 20 - }).then(data => { - User.findById(data._id).should.exist; - return data; - }).then(data => User.removeById(data._id))); - - it('save() - replace', () => User.insert({ - name: {first: 'John', last: 'Doe'}, - email: 'abc@example.com', - age: 20 - }).then(data => { - data.age = 30; - return User.save(data); - }).then(data => { - data.age.should.eql(30); - return data; - }).then(data => User.removeById(data._id))); - - it('save() - sync problem', () => { - const id = 'cuid' + nanoid(); - - return Promise.all([ - User.save({_id: id, age: 1}), - User.save({_id: id, age: 2}) - ]).then(() => { - const user = User.findById(id); - - user.age.should.eql(2); - User.should.to.have.length(1); - - return User.removeById(id); - }); - }); - - it('updateById()', () => { - const listener = sinon.spy(data => { - User.findById(data._id).age.should.eql(30); - }); - - User.once('update', listener); - - return User.insert({ - name: {first: 'John', last: 'Doe'}, - email: 'abc@example.com', - age: 20 - }).then(data => User.updateById(data._id, {age: 30})).then(data => { - data.age.should.eql(30); - listener.calledOnce.should.be.true; - return data; - }).then(data => User.removeById(data._id)); - }); - - it('updateById() - object', () => User.insert({ - name: {first: 'John', last: 'Doe'}, - email: 'abc@example.com', - age: 20 - }).then(data => User.updateById(data._id, {name: {first: 'Jerry'}})).then(data => { - data.name.first.should.eql('Jerry'); - data.name.last.should.eql('Doe'); - return data; - }).then(data => User.removeById(data._id))); - - it('updateById() - dot notation', () => User.insert({ - name: {first: 'John', last: 'Doe'}, - email: 'abc@example.com', - age: 20 - }).then(data => User.updateById(data._id, {'name.last': 'Smith'})).then(data => { - data.name.first.should.eql('John'); - data.name.last.should.eql('Smith'); - return data; - }).then(data => User.removeById(data._id))); - - it('updateById() - operator', () => User.insert({ - name: {first: 'John', last: 'Doe'}, - email: 'abc@example.com', - age: 20 - }).then(data => User.updateById(data._id, {age: {$inc: 5}})).then(data => { - data.age.should.eql(25); - return data; - }).then(data => User.removeById(data._id))); - - it('updateById() - operator in first class', () => User.insert({ - name: {first: 'John', last: 'Doe'}, - email: 'abc@example.com', - age: 20 - }).then(data => User.updateById(data._id, {$inc: {age: 5}})).then(data => { - data.age.should.eql(25); - return data; - }).then(data => User.removeById(data._id))); - - it('updateById() - $set', () => User.insert({ - name: {first: 'John', last: 'Doe'}, - email: 'abc@example.com', - age: 20 - }).then(data => User.updateById(data._id, {$set: {age: 25}})).then(data => { - data.age.should.eql(25); - return data; - }).then(data => User.removeById(data._id))); - - it('updateById() - $unset', () => User.insert({ - name: {first: 'John', last: 'Doe'}, - email: 'abc@example.com', - age: 20 - }).then(data => User.updateById(data._id, {$unset: {email: true}})).then(data => { - should.not.exist(data.email); - return data; - }).then(data => User.removeById(data._id))); - - it('updateById() - $unset false', () => User.insert({ - name: {first: 'John', last: 'Doe'}, - email: 'abc@example.com', - age: 20 - }).then(data => User.updateById(data._id, {$unset: {email: false}})).then(data => { - data.email.should.eql('abc@example.com'); - return data; - }).then(data => User.removeById(data._id))); - - it('updateById() - $rename', () => User.insert({ - name: {first: 'John', last: 'Doe'}, - email: 'abc@example.com', - age: 20 - }).then(data => User.updateById(data._id, {$rename: {email: 'address'}})).then(data => { - data.address.should.eql('abc@example.com'); - should.not.exist(data.email); - return data; - }).then(data => User.removeById(data._id))); - - it('updateById() - id not exist', () => (User.updateById('foo', {}) as any).should.eventually.be.rejected); - - it('updateById() - hook', () => { - const db = new Database(); - const testSchema = new Schema(); - const Test = db.model('Test', testSchema); - - const preHook = sinon.spy(data => { - should.not.exist(Test.findById(data._id).baz); - }); - - const postHook = sinon.spy(data => { - Test.findById(data._id).baz.should.eql(1); - }); - - return Test.insert({ - foo: 'bar' - }).then(data => { - testSchema.pre('save', preHook); - testSchema.post('save', postHook); - - return Test.updateById(data._id, {baz: 1}); - }).then(() => { - preHook.calledOnce.should.be.true; - postHook.calledOnce.should.be.true; - }); - }); - - it('update()', () => User.insert([ - {age: 10}, - {age: 20}, - {age: 30}, - {age: 20}, - {age: 40} - ]).then(data => User.update({age: 20}, {email: 'A'}).then(updated => { - updated[0]._id.should.eql(data[1]._id); - updated[1]._id.should.eql(data[3]._id); - updated[0].email.should.eql('A'); - updated[1].email.should.eql('A'); - return data; - })).map(item => User.removeById(item._id))); - - it('replaceById()', () => { - function validate(data) { - data.name.first.should.eql('Mary'); - data.name.last.should.eql('White'); - data.age.should.eql(40); - data.should.not.ownProperty('email'); - } - - const listener = sinon.spy(data => { - validate(User.findById(data._id)); - }); - - User.once('update', listener); - - return User.insert({ - name: {first: 'John', last: 'Doe'}, - email: 'abc@example.com', - age: 20 - }).then(data => User.replaceById(data._id, { - name: {first: 'Mary', last: 'White'}, - age: 40 - })).then(data => { - validate(data); - listener.calledOnce.should.be.true; - return data; - }).then(data => User.removeById(data._id)); - }); - - it('replaceById() - id not exist', () => (User.replaceById('foo', {}) as any).should.eventually.be.rejected); - - it('replaceById() - pre-hook', () => { - const db = new Database(); - const testSchema = new Schema(); - const Test = db.model('Test', testSchema); - - const preHook = sinon.spy(data => { - Test.findById(data._id).foo.should.eql('bar'); - }); - - const postHook = sinon.spy(data => { - Test.findById(data._id).foo.should.eql('baz'); - }); - - return Test.insert({ - foo: 'bar' - }).then(data => { - testSchema.pre('save', preHook); - testSchema.post('save', postHook); - - return Test.replaceById(data._id, {foo: 'baz'}); - }).then(() => { - preHook.calledOnce.should.be.true; - postHook.calledOnce.should.be.true; - }); - }); - - it('replace()', () => User.insert([ - {age: 10}, - {age: 20}, - {age: 30}, - {age: 20}, - {age: 40} - ]).then(data => User.replace({age: 20}, {email: 'A'}).then(updated => { - updated[0]._id.should.eql(data[1]._id); - updated[1]._id.should.eql(data[3]._id); - updated[0].email.should.eql('A'); - updated[1].email.should.eql('A'); - return data; - })).map(item => User.removeById(item._id))); - - it('removeById()', () => { - const listener = sinon.spy(data => { - should.not.exist(User.findById(data._id)); - }); - - User.once('remove', listener); - - return User.insert({ - name: {first: 'John', last: 'Doe'}, - email: 'abc@example.com', - age: 20 - }).then(data => User.removeById(data._id)).then(data => { - listener.calledOnce.should.be.true; - should.not.exist(User.findById(data._id)); - }); - }); - - it('removeById() - id not exist', () => (User.removeById('foo', () => {}) as any).should.eventually.be.rejected); - - it('removeById() - hook', () => { - const db = new Database(); - const testSchema = new Schema(); - const Test = db.model('Test', testSchema); - - const preHook = sinon.spy(data => { - Test.findById(data._id).should.exist; - }); - - const postHook = sinon.spy(data => { - should.not.exist(Test.findById(data._id)); - }); - - testSchema.pre('remove', preHook); - testSchema.post('remove', postHook); - - return Test.insert({ - foo: 'bar' - }).then(data => Test.removeById(data._id)).then(() => { - preHook.calledOnce.should.be.true; - postHook.calledOnce.should.be.true; - }); - }); - - it('remove()', () => User.insert([ - {age: 10}, - {age: 20}, - {age: 30}, - {age: 20}, - {age: 40} - ]).then(data => User.remove({age: 20}).then(removed => { - should.not.exist(User.findById(data[1]._id)); - should.not.exist(User.findById(data[3]._id)); - return [data[0], data[2], data[4]]; - })).map(item => User.removeById(item._id))); - - it('destroy()', () => { - const Test = db.model('Test'); - Test.destroy(); - should.not.exist(db._models.Test); - }); - - it('count()', () => { - Post.should.to.have.length(Post.count()); - }); - - it('forEach()', () => { - let count = 0; - - return Post.insert(Array(10).fill({})).then(data => { - Post.forEach((item, i) => { - item.should.eql(data[i]); - i.should.eql(count++); - }); - - count.should.eql(data.length); - return data; - }).map(item => Post.removeById(item._id)); - }); - - it('toArray()', () => Post.insert(Array(10).fill({})).then(data => { - Post.toArray().should.eql(data); - return data; - }).map(item => Post.removeById(item._id))); - - it('find()', () => User.insert([ - {age: 10}, - {age: 20}, - {age: 20}, - {age: 30}, - {age: 40} - ]).then(data => { - const query = User.find({age: 20}) as Query; - query.data.should.eql(data.slice(1, 3)); - return data; - }).map(item => User.removeById(item._id))); - - it('find() - blank', () => User.insert([ - {age: 10}, - {age: 20}, - {age: 20}, - {age: 30}, - {age: 40} - ]).then(data => { - const query = User.find({}) as Query; - query.data.should.eql(data); - return data; - }).map(item => User.removeById(item._id))); - - it('find() - operator', () => User.insert([ - {age: 10}, - {age: 20}, - {age: 30}, - {age: 40} - ]).then(data => { - const query = User.find({age: {$gt: 20}}) as Query; - query.data.should.eql(data.slice(2)); - return data; - }).map(item => User.removeById(item._id))); - - it('find() - limit', () => User.insert([ - {age: 10}, - {age: 20}, - {age: 30}, - {age: 40} - ]).then(data => { - const query = User.find({age: {$gte: 20}}, {limit: 2}) as Query; - query.data.should.eql(data.slice(1, 3)); - return data; - }).map(item => User.removeById(item._id))); - - it('find() - skip', () => User.insert([ - {age: 10}, - {age: 20}, - {age: 30}, - {age: 40} - ]).then(data => { - let query = User.find({age: {$gte: 20}}, {skip: 1}) as Query; - query.data.should.eql(data.slice(2)); - - // with limit - query = User.find({age: {$gte: 20}}, {limit: 1, skip: 1}) as Query; - query.data.should.eql(data.slice(2, 3)); - - return data; - }).map(item => User.removeById(item._id))); - - it('find() - lean', () => User.insert([ - {age: 10}, - {age: 20}, - {age: 30}, - {age: 40} - ]).then(data => { - const query = User.find({age: {$gt: 20}}, {lean: true}); - query.should.be.a('array'); - return data; - }).map(item => User.removeById(item._id))); - - it('find() - $and', () => User.insert([ - {name: {first: 'John', last: 'Doe'}, age: 20}, - {name: {first: 'Jane', last: 'Doe'}, age: 25}, - {name: {first: 'Jack', last: 'White'}, age: 30} - ]).then(data => { - const query = User.find({ - $and: [ - {'name.last': 'Doe'}, - {age: {$gt: 20}} - ] - }); - - (query as Query).toArray().should.eql([data[1]]); - - return data; - }).map(item => User.removeById(item._id))); - - it('find() - $or', () => User.insert([ - {name: {first: 'John', last: 'Doe'}, age: 20}, - {name: {first: 'Jane', last: 'Doe'}, age: 25}, - {name: {first: 'Jack', last: 'White'}, age: 30} - ]).then(data => { - const query = User.find({ - $or: [ - {'name.last': 'White'}, - {age: {$gt: 20}} - ] - }); - - (query as Query).toArray().should.eql(data.slice(1)); - - return data; - }).map(item => User.removeById(item._id))); - - it('find() - $nor', () => User.insert([ - {name: {first: 'John', last: 'Doe'}, age: 20}, - {name: {first: 'Jane', last: 'Doe'}, age: 25}, - {name: {first: 'Jack', last: 'White'}, age: 30} - ]).then(data => { - const query = User.find({ - $nor: [ - {'name.last': 'White'}, - {age: {$gt: 20}} - ] - }); - - (query as Query).toArray().should.eql([data[0]]); - - return data; - }).map(item => User.removeById(item._id))); - - it('find() - $not', () => User.insert([ - {name: {first: 'John', last: 'Doe'}, age: 20}, - {name: {first: 'Jane', last: 'Doe'}, age: 25}, - {name: {first: 'Jack', last: 'White'}, age: 30} - ]).then(data => { - const query = User.find({ - $not: {'name.last': 'Doe'} - }); - - (query as Query).toArray().should.eql(data.slice(2)); - - return data; - }).map(item => User.removeById(item._id))); - - it('find() - $where', () => User.insert([ - {name: {first: 'John', last: 'Doe'}, age: 20}, - {name: {first: 'Jane', last: 'Doe'}, age: 25}, - {name: {first: 'Jack', last: 'White'}, age: 30} - ]).then(data => { - const query = User.find({ - $where: function() { - return this.name.last === 'Doe'; - } - }); - - (query as Query).toArray().should.eql(data.slice(0, 2)); - - return data; - }).map(item => User.removeById(item._id))); - - it('findOne()', () => User.insert([ - {age: 10}, - {age: 20}, - {age: 30}, - {age: 40} - ]).then(data => { - User.findOne({age: {$gt: 20}}).should.eql(data[2]); - return data; - }).map(item => User.removeById(item._id))); - - it('findOne() - lean', () => User.insert([ - {age: 10}, - {age: 20}, - {age: 30}, - {age: 40} - ]).then(data => { - (User.findOne({age: {$gt: 20}}, {lean: true}) as Document)._id!.should.eql(data[2]._id); - return data; - }).map(item => User.removeById(item._id))); - - it('sort()', () => User.insert([ - {age: 15}, - {age: 35}, - {age: 10} - ]).then(data => { - const query = User.sort('age'); - query.data[0].should.eql(data[2]); - query.data[1].should.eql(data[0]); - query.data[2].should.eql(data[1]); - return data; - }).map(item => User.removeById(item._id))); - - it('sort() - descending', () => User.insert([ - {age: 15}, - {age: 35}, - {age: 10} - ]).then(data => { - const query = User.sort('age', -1); - query.data[0].should.eql(data[1]); - query.data[1].should.eql(data[0]); - query.data[2].should.eql(data[2]); - return data; - }).map(item => User.removeById(item._id))); - - it('sort() - multi', () => User.insert([ - {age: 15, email: 'A'}, - {age: 30, email: 'B'}, - {age: 20, email: 'C'}, - {age: 20, email: 'D'} - ]).then(data => { - const query = User.sort('age email'); - query.data[0].should.eql(data[0]); - query.data[1].should.eql(data[2]); - query.data[2].should.eql(data[3]); - query.data[3].should.eql(data[1]); - return data; - }).map(item => User.removeById(item._id))); - - it('eq()', () => Post.insert(Array(5).fill({})).then(data => { - for (let i = 0, len = data.length; i < len; i++) { - Post.eq(i).should.eql(data[i]); - } - - return data; - }).map(item => Post.removeById(item._id))); - - it('eq() - negative index', () => Post.insert(Array(5).fill({})).then(data => { - for (let i = 1, len = data.length; i <= len; i++) { - Post.eq(-i).should.eql(data[len - i]); - } - - return data; - }).map(item => Post.removeById(item._id))); - - it('eq() - no data', () => { - (typeof Post.eq(1)).should.eql('undefined'); - }); - - it('first()', () => Post.insert(Array(5).fill({})).then(data => { - Post.first().should.eql(data[0]); - - return data; - }).map(item => Post.removeById(item._id))); - - it('last()', () => Post.insert(Array(5).fill({})).then(data => { - Post.last().should.eql(data[data.length - 1]); - - return data; - }).map(item => Post.removeById(item._id))); - - it('slice() - no arguments', () => Post.insert(Array(5).fill({})).then(data => { - Post.slice().data.should.eql(data); - return data; - }).map(item => Post.removeById(item._id))); - - it('slice() - one argument', () => Post.insert(Array(5).fill({})).then(data => { - Post.slice(2).data.should.eql(data.slice(2)); - return data; - }).map(item => Post.removeById(item._id))); - - it('slice() - one negative argument', () => Post.insert(Array(5).fill({})).then(data => { - Post.slice(-2).data.should.eql(data.slice(-2)); - return data; - }).map(item => Post.removeById(item._id))); - - it('slice() - two arguments', () => Post.insert(Array(5).fill({})).then(data => { - Post.slice(2, 4).data.should.eql(data.slice(2, 4)); - return data; - }).map(item => Post.removeById(item._id))); - - it('slice() - start + negative end index', () => Post.insert(Array(5).fill({})).then(data => { - Post.slice(1, -1).data.should.eql(data.slice(1, -1)); - return data; - }).map(item => Post.removeById(item._id))); - - it('slice() - two negative arguments', () => Post.insert(Array(5).fill({})).then(data => { - Post.slice(-3, -1).data.should.eql(data.slice(-3, -1)); - return data; - }).map(item => Post.removeById(item._id))); - - it('slice() - start > end', () => Post.insert(Array(5).fill({})).then(data => { - Post.slice(-1, -3).data.should.eql(data.slice(-1, -3)); - return data; - }).map(item => Post.removeById(item._id))); - - it('slice() - index overflow', () => Post.insert(Array(5).fill({})).then(data => { - Post.slice(1, 100).data.should.eql(data.slice(1, 100)); - return data; - }).map(item => Post.removeById(item._id))); - - it('slice() - index overflow 2', () => Post.insert(Array(5).fill({})).then(data => { - Post.slice(100, 200).data.should.eql(data.slice(100, 200)); - return data; - }).map(item => Post.removeById(item._id))); - - it('limit()', () => Post.insert(Array(5).fill({})).then(data => { - Post.limit(2).data.should.eql(data.slice(0, 2)); - return data; - }).map(item => Post.removeById(item._id))); - - it('skip()', () => Post.insert(Array(5).fill({})).then(data => { - Post.skip(2).data.should.eql(data.slice(2)); - return data; - }).map(item => Post.removeById(item._id))); - - it('reverse()', () => Post.insert(Array(5).fill({})).then(data => { - const query = Post.reverse(); - - for (let i = 0, len = data.length; i < len; i++) { - query.data[i].should.eql(data[len - i - 1]); - } - - return data; - }).map(item => Post.removeById(item._id))); - - it('shuffle()', () => Post.insert(Array(5).fill({})).then(data => { - const query = Post.shuffle(); - sortBy(query.data, '_id').should.eql(sortBy(data, '_id')); - return data; - }).map(item => Post.removeById(item._id))); - - it('map()', () => Post.insert(Array(5).fill({})).then(data => { - let num = 0; - - const d1 = Post.map((item, i) => { - i.should.eql(num++); - return item._id; - }); - - const d2 = data.map(item => item._id); - - d1.should.eql(d2); - - return data; - }).map(item => Post.removeById(item._id))); - - it('reduce()', () => Post.insert([ - {title: 'A'}, - {title: 'B'}, - {title: 'C'} - ]).then(data => { - let num = 1; - - const sum = Post.reduce((sum, item, i) => { - i.should.eql(num++); - return {title: sum.title + item.title}; - }); - - sum.title.should.eql('ABC'); - - return data; - }).map(item => Post.removeById(item._id))); - - it('reduce() - with initial', () => Post.insert([ - {title: 'A'}, - {title: 'B'}, - {title: 'C'} - ]).then(data => { - let num = 0; - - const sum = Post.reduce((sum, item, i) => { - i.should.eql(num++); - return sum + item.title; - }, '_'); - - sum.should.eql('_ABC'); - - return data; - }).map(item => Post.removeById(item._id))); - - it('reduceRight()', () => Post.insert([ - {title: 'A'}, - {title: 'B'}, - {title: 'C'} - ]).then(data => { - let num = 1; - - const sum = Post.reduceRight((sum, item, i) => { - i.should.eql(num--); - return {title: sum.title + item.title}; - }); - - sum.title.should.eql('CBA'); - - return data; - }).map(item => Post.removeById(item._id))); - - it('reduceRight() - with initial', () => Post.insert([ - {title: 'A'}, - {title: 'B'}, - {title: 'C'} - ]).then(data => { - let num = 2; - - const sum = Post.reduceRight((sum, item, i) => { - i.should.eql(num--); - return sum + item.title; - }, '_'); - - sum.should.eql('_CBA'); - - return data; - }).map(item => Post.removeById(item._id))); - - it('filter()', () => User.insert([ - {age: 10}, - {age: 20}, - {age: 30}, - {age: 40} - ]).then(data => { - let num = 0; - - const query = User.filter((data, i) => { - i.should.eql(num++); - return data.age > 20; - }); - - query.data.should.eql(data.slice(2)); - - return data; - }).map(item => User.removeById(item._id))); - - it('every()', () => User.insert([ - {age: 10}, - {age: 20}, - {age: 30}, - {age: 40} - ]).then(data => { - let num = 0; - - User.every((data, i) => { - i.should.eql(num++); - return data.age; - }).should.be.true; - - User.every((data, i) => data.age > 10).should.be.false; - - return data; - }).map(item => User.removeById(item._id))); - - it('some()', () => User.insert([ - {age: 10}, - {age: 20}, - {age: 30}, - {age: 40} - ]).then(data => { - let num = 0; - - User.some((data, i) => data.age > 10).should.be.true; - - User.some((data, i) => { - i.should.eql(num++); - return data.age < 0; - }).should.be.false; - - return data; - }).map(item => User.removeById(item._id))); - - it('populate() - error', () => { - try { - // @ts-expect-error - Post.populate(); - } catch (err) { - err.message.should.eql('path is required'); - } - }); - - it('populate() - not exist', () => { - let posts, user; - - return Post.insert([ - {title: 'ABCD'}, - {title: 'ACD'}, - {title: 'CDE'}, - {title: 'XYZ'} - ]).then(posts_ => { - posts = posts_; - - return User.insert({ - posts: posts.map(post => post._id) - }); - }).then(user_ => { - user = user_; - return User.populate({ - path: 'posts', - model: 'ppp' - }); - }).catch(err => { - err.message.should.eql('Model `ppp` does not exist'); - return Promise.all([ - User.removeById(user._id), - Post.removeById(posts[0]._id), - Post.removeById(posts[1]._id), - Post.removeById(posts[2]._id), - Post.removeById(posts[3]._id) - ]); - }); - }); - - it('populate() - object', () => { - let user, post; - - return User.insert({}).then(user_ => { - user = user_; - - return Post.insert({ - user_id: user_._id - }); - }).then(post_ => { - post = post_; - return Post.populate('user_id'); - }).then(result => { - result.first().user_id.should.eql(user); - - return Promise.all([ - User.removeById(user._id), - Post.removeById(post._id) - ]); - }); - }); - - it('populate() - array', () => { - let posts, user; - - return Post.insert([ - {title: 'ABCD'}, - {title: 'ACD'}, - {title: 'CDE'}, - {title: 'XYZ'} - ]).then(posts_ => { - posts = posts_; - - return User.insert({ - posts: posts.map(post => post._id) - }); - }).then(user_ => { - user = user_; - return User.populate('posts'); - }).then(result => { - const query = result.first().posts; - - query.should.be.an.instanceOf(Post.Query); - query.toArray().should.eql(posts); - - return Promise.all([ - User.removeById(user._id), - Post.removeById(posts[0]._id), - Post.removeById(posts[1]._id), - Post.removeById(posts[2]._id), - Post.removeById(posts[3]._id) - ]); - }); - }); - - it('populate() - match', () => { - let posts, user; - - return Post.insert([ - {title: 'ABCD'}, - {title: 'ACD'}, - {title: 'CDE'}, - {title: 'XYZ'} - ]).then(posts_ => { - posts = posts_; - - return User.insert({ - posts: posts.map(post => post._id) - }); - }).then(user_ => { - user = user_; - return User.populate({ - path: 'posts', - match: {title: /^A/} - }); - }).then(result => { - result.first().posts.toArray().should.eql(posts.slice(0, 2)); - - return Promise.all([ - User.removeById(user._id), - Post.removeById(posts[0]._id), - Post.removeById(posts[1]._id), - Post.removeById(posts[2]._id), - Post.removeById(posts[3]._id) - ]); - }); - }); - - it('populate() - sort', () => { - let posts, user; - - return Post.insert([ - {title: 'XYZ'}, - {title: 'ABCD'}, - {title: 'CDE'}, - {title: 'ACD'} - ]).then(posts_ => { - posts = posts_; - - return User.insert({ - posts: posts.map(post => post._id) - }); - }).then(user_ => { - user = user_; - - return User.populate({ - path: 'posts', - sort: 'title' - }); - }).then(result => { - result.first().posts.toArray().should.eql([ - posts[1], - posts[3], - posts[2], - posts[0] - ]); - - return Promise.all([ - User.removeById(user._id), - Post.removeById(posts[0]._id), - Post.removeById(posts[1]._id), - Post.removeById(posts[2]._id), - Post.removeById(posts[3]._id) - ]); - }); - }); - - it('populate() - limit', () => { - let posts, user; - - return Post.insert([ - {title: 'XYZ'}, - {title: 'ABCD'}, - {title: 'CDE'}, - {title: 'ACD'} - ]).then(posts_ => { - posts = posts_; - - return User.insert({ - posts: posts.map(post => post._id) - }); - }).then(user_ => { - user = user_; - - return User.populate({ - path: 'posts', - limit: 2 - }); - }).then(result => { - result.first().posts.toArray().should.eql(posts.slice(0, 2)); - - // with match - return User.populate({ - path: 'posts', - match: {title: /D/}, - limit: 2 - }); - }).then(result => { - result.first().posts.toArray().should.eql(posts.slice(1, 3)); - - return Promise.all([ - User.removeById(user._id), - Post.removeById(posts[0]._id), - Post.removeById(posts[1]._id), - Post.removeById(posts[2]._id), - Post.removeById(posts[3]._id) - ]); - }); - }); - - it('populate() - skip', () => { - let posts, user; - - return Post.insert([ - {title: 'XYZ'}, - {title: 'ABCD'}, - {title: 'CDE'}, - {title: 'ACD'} - ]).then(posts_ => { - posts = posts_; - - return User.insert({ - posts: posts.map(post => post._id) - }); - }).then(user_ => { - user = user_; - - return User.populate({ - path: 'posts', - skip: 2 - }); - }).then(result => { - result.first().posts.toArray().should.eql(posts.slice(2)); - - // with match - return User.populate({ - path: 'posts', - match: {title: /D/}, - skip: 2 - }); - }).then(result => { - result.first().posts.toArray().should.eql(posts.slice(3)); - - // with limit - return User.populate({ - path: 'posts', - limit: 2, - skip: 1 - }); - }).then(result => { - result.first().posts.toArray().should.eql(posts.slice(1, 3)); - - // with match & limit - return User.populate({ - path: 'posts', - match: {title: /D/}, - limit: 2, - skip: 1 - }); - }).then(result => { - result.first().posts.toArray().should.eql(posts.slice(2)); - - return Promise.all([ - User.removeById(user._id), - Post.removeById(posts[0]._id), - Post.removeById(posts[1]._id), - Post.removeById(posts[2]._id), - Post.removeById(posts[3]._id) - ]); - }); - }); - - it('static method', () => { - const schema = new Schema(); - - schema.static('add', function(value) { - return this.insert(value); - }); - - const Test = db.model('Test', schema); - - (Test as any).add({name: 'foo'}).then(data => { - data.name.should.eql('foo'); - }); - - Test.destroy(); - }); - - it('instance method', () => { - const schema = new Schema(); - - schema.method('getName', function() { - return this.name; - }); - - const Test = db.model('Test', schema); - - Test.insert({name: 'foo'}).then(data => { - data.getName().should.eql('foo'); - }); - - Test.destroy(); - }); - - it('_import()', () => { - const schema = new Schema({ - _id: {type: String, required: true}, - bool: Boolean - }); - - const Test = db.model('Test', schema); - - Test._import([ - {_id: 'A', bool: 1}, - {_id: 'B', bool: 0} - ]); - - Test.should.to.have.length(2); - - Test.toArray().should.eql([ - Test.new({_id: 'A', bool: true}), - Test.new({_id: 'B', bool: false}) - ]); - - Test.destroy(); - }); - - it('_export()', () => { - const schema = new Schema({ - _id: {type: String, required: true}, - bool: Boolean - }); - - const Test = db.model('Test', schema); - - return Test.insert([ - {_id: 'A', bool: true}, - {_id: 'B', bool: false} - ]).then(data => { - Test._export().should.eql(JSON.stringify([ - {_id: 'A', bool: 1}, - {_id: 'B', bool: 0} - ])); - - return Test.destroy(); - }); - }); - - it('_export() - should not save undefined value', () => { - // @ts-ignore - class CacheType extends SchemaType { - value() {} - } - - const schema = new Schema({ - cache: CacheType - }); - - const Test = db.model('Test', schema); - - return Test.insert({ - cache: 'test' - }).then(data => { - data.cache.should.exist; - should.not.exist(JSON.parse(Test._export())[0].cache); - - return Test.destroy(); - }); - }); -}); diff --git a/media/scripts/mutex.ts b/media/scripts/mutex.ts deleted file mode 100644 index 7157285a..00000000 --- a/media/scripts/mutex.ts +++ /dev/null @@ -1,32 +0,0 @@ -import chai from 'chai'; -const should = chai.should(); // eslint-disable-line -import Mutex from '../../dist/mutex'; -import sinon from 'sinon'; - -describe('Mutex', () => { - it('mutex test', callback => { - const mutex = new Mutex(); - let fn2; - - const fn1 = sinon.spy(() => { - setTimeout(() => { - fn2.called.should.be.false; - mutex.unlock(); - }, 20); - }); - - fn2 = sinon.spy(() => { - fn1.calledOnce.should.be.true; - mutex.unlock(); - }); - - mutex.lock(fn1); - mutex.lock(fn2); - - mutex.lock(() => { - fn1.calledOnce.should.be.true; - fn2.calledOnce.should.be.true; - callback(); - }); - }); -}); diff --git a/media/scripts/query.ts b/media/scripts/query.ts deleted file mode 100644 index af5adaa1..00000000 --- a/media/scripts/query.ts +++ /dev/null @@ -1,671 +0,0 @@ -import chai from 'chai'; -const should = chai.should(); // eslint-disable-line -import lodash from 'lodash'; -const { sortBy } = lodash; -import Promise from 'bluebird'; -import Document from '../../dist/document'; -import Database from '../../dist/database'; -import type Query from '../../dist/query'; -import type Model from '../../dist/model'; - -interface UserType { - name?: string; - age?: number; - comments?: string; -} - -interface LoopType { - age: { - age: number; - } -} - -describe('Query', () => { - - const db = new Database(); - const Schema = Database.Schema; - - const User: Model = db.model('User', { - name: String, - age: Number, - comments: [{type: Schema.Types.CUID, ref: 'Comment'}] - }); - - const Loop: Model = db.model('Loop', { - age: { - age: Number - } - }); - - const Comment = db.model('Comment', { - content: String, - author: {type: Schema.Types.CUID, ref: 'User'} - }); - - it('count()', () => User.insert(Array(5).fill({})).then(data => { - User.find({}).count().should.eql(data.length); - return data; - }).map(item => User.removeById(item._id))); - - it('forEach()', () => User.insert(Array(5).fill({})).then(data => { - let count = 0; - - User.find({}).forEach((item, i) => { - item.should.eql(data[i]); - i.should.eql(count++); - }); - - return data; - }).map(item => User.removeById(item._id))); - - it('toArray()', () => User.insert(Array(5).fill({})).then(data => { - User.find({}).toArray().should.eql(data); - return data; - }).map(item => User.removeById(item._id))); - - it('eq()', () => User.insert(Array(5).fill({})).then(data => { - const query = User.find({}); - - for (let i = 0, len = data.length; i < len; i++) { - query.eq(i).should.eql(data[i]); - } - - return data; - }).map(item => User.removeById(item._id))); - - it('eq() - negative index', () => User.insert(Array(5).fill({})).then(data => { - const query = User.find({}); - - for (let i = 1, len = data.length; i <= len; i++) { - query.eq(-i).should.eql(data[len - i]); - } - - return data; - }).map(item => User.removeById(item._id))); - - it('first()', () => User.insert(Array(5).fill({})).then(data => { - User.find({}).first().should.eql(data[0]); - return data; - }).map(item => User.removeById(item._id))); - - it('last()', () => User.insert(Array(5).fill({})).then(data => { - User.find({}).last().should.eql(data[data.length - 1]); - return data; - }).map(item => User.removeById(item._id))); - - it('slice()', () => User.insert(Array(5).fill({})).then(data => { - User.find({}).slice(2, 4).data.should.eql(data.slice(2, 4)); - return data; - }).map(item => User.removeById(item._id))); - - it('limit()', () => User.insert(Array(5).fill({})).then(data => { - User.find({}).limit(2).data.should.eql(data.slice(0, 2)); - return data; - }).map(item => User.removeById(item._id))); - - it('skip()', () => User.insert(Array(5).fill({})).then(data => { - User.find({}).skip(2).data.should.eql(data.slice(2)); - return data; - }).map(item => User.removeById(item._id))); - - it('reverse()', () => User.insert(Array(5).fill({})).then(data => { - User.find({}).reverse().data.should.eql(data.reverse()); - return data; - }).map(item => User.removeById(item._id))); - - it('shuffle()', () => User.insert(Array(5).fill({})).then(data => { - sortBy(User.find({}).shuffle().data, '_id').should.eql(sortBy(data, '_id')); - return data; - }).map(item => User.removeById(item._id))); - - it('find()', () => User.insert([ - {age: 10}, - {age: 20}, - {age: 20}, - {age: 30}, - {age: 40} - ]).then(data => { - const query = User.find({}).find({age: 20}); - query.data.should.eql(data.slice(1, 3)); - - const { length } = query; - - for (let i = 0; i < length; i++) { - query.data[i].should.to.be.an.instanceof(Document); - } - return data; - }).map(item => User.removeById(item._id))); - - it('find() - blank', () => User.insert([ - {age: 10}, - {age: 20}, - {age: 20}, - {age: 30}, - {age: 40} - ]).then(data => { - const query = User.find({}).find({}); - query.data.should.eql(data); - return data; - }).map(item => User.removeById(item._id))); - - it('find() - operator', () => User.insert([ - {age: 10}, - {age: 20}, - {age: 30}, - {age: 40} - ]).then(data => { - const query = User.find({}).find({age: {$gt: 20}}); - query.data.should.eql(data.slice(2)); - return data; - }).map(item => User.removeById(item._id))); - - it('find() - limit', () => User.insert([ - {age: 10}, - {age: 20}, - {age: 30}, - {age: 40} - ]).then(data => { - const query = User.find({}).find({age: {$gte: 20}}, {limit: 2}) as Query; - query.data.should.eql(data.slice(1, 3)); - return data; - }).map(item => User.removeById(item._id))); - - it('find() - skip', () => User.insert([ - {age: 10}, - {age: 20}, - {age: 30}, - {age: 40} - ]).then(data => { - let query = User.find({}).find({age: {$gte: 20}}, {skip: 1}) as Query; - query.data.should.eql(data.slice(2)); - - // with limit - query = User.find({}).find({age: {$gte: 20}}, {limit: 1, skip: 1}) as Query; - query.data.should.eql(data.slice(2, 3)); - - return data; - }).map(item => User.removeById(item._id))); - - it('find() - lean', () => User.insert([ - {age: 10}, - {age: 20}, - {age: 30}, - {age: 40} - ]).then(data => { - const query = User.find({}).find({age: {$gt: 20}}, {lean: true}) as Query; - query.should.be.a('array'); - const { length } = query; - for (let i = 0; i < length; i++) { - query[i].should.to.not.be.an.instanceof(Document); - } - return data; - }).map(item => User.removeById(item._id))); - - it('find() - $and', () => User.insert([ - {name: 'John', age: 20}, - {name: 'John', age: 25}, - {name: 'Jack', age: 30} - ]).then(data => { - const query = User.find({}).find({ - $and: [ - {name: 'John'}, - {age: {$gt: 20}} - ] - }); - - query.toArray().should.eql([data[1]]); - - return data; - }).map(item => User.removeById(item._id))); - - it('find() - $or', () => User.insert([ - {name: 'John', age: 20}, - {name: 'John', age: 25}, - {name: 'Jack', age: 30} - ]).then(data => { - const query = User.find({}).find({ - $or: [ - {name: 'Jack'}, - {age: {$gt: 20}} - ] - }); - - query.toArray().should.eql(data.slice(1)); - - return data; - }).map(item => User.removeById(item._id))); - - it('find() - $nor', () => User.insert([ - {name: 'John', age: 20}, - {name: 'John', age: 25}, - {name: 'Jack', age: 30} - ]).then(data => { - const query = User.find({}).find({ - $nor: [ - {name: 'Jack'}, - {age: {$gt: 20}} - ] - }); - - query.toArray().should.eql([data[0]]); - - return data; - }).map(item => User.removeById(item._id))); - - it('find() - $not', () => User.insert([ - {name: 'John', age: 20}, - {name: 'John', age: 25}, - {name: 'Jack', age: 30} - ]).then(data => { - const query = User.find({}).find({ - $not: {name: 'John'} - }); - - query.toArray().should.eql([data[2]]); - - return data; - }).map(item => User.removeById(item._id))); - - it('find() - $where', () => User.insert([ - {name: 'John', age: 20}, - {name: 'John', age: 25}, - {name: 'Jack', age: 30} - ]).then(data => { - const query = User.find({}).find({ - $where() { - return this.name === 'John'; - } - }); - - query.toArray().should.eql(data.slice(0, 2)); - - return data; - }).map(item => User.removeById(item._id))); - - it('find() - abnormal - 1', () => User.insert([ - {name: 'John', age: 20}, - {name: 'John', age: 25}, - {name: 'Jack', age: 30} - ]).then(data => { - const query = User.find({}).find({ - $and: [ - {name: 'Jack'}, - {age: {gt: 20}} - ] - }); - query.toArray().length.should.eql(0); - - return data; - }).map(item => User.removeById(item._id))); - - it('find() - abnormal - 2', () => User.insert([ - {name: 'John', age: 20}, - {name: 'John', age: 25}, - {name: 'Jack', age: 30} - ]).then(data => { - const query = User.find({}).find({ - $and: [ - {name: 'Jack'}, - {age: {gt: {}}} - ] - }); - query.toArray().should.eql([data[2]]); - - return data; - }).map(item => User.removeById(item._id))); - - it('findOne()', () => User.insert([ - {age: 10}, - {age: 20}, - {age: 30}, - {age: 40} - ]).then(data => { - const result = User.find({}).findOne({age: {$gt: 20}}); - result.should.eql(data[2]); - result.should.to.be.an.instanceof(Document); - return data; - }).map(item => User.removeById(item._id))); - - it('findOne() - lean', () => User.insert([ - {age: 10}, - {age: 20}, - {age: 30}, - {age: 40} - ]).then(data => { - const result = User.find({}).findOne({age: {$gt: 20}}, {lean: true}) as Document; - result._id!.should.eql(data[2]._id); - result.should.to.not.be.an.instanceof(Document); - return data; - }).map(item => User.removeById(item._id))); - - it('sort()', () => User.insert([ - {age: 15}, - {age: 35}, - {age: 10} - ]).then(data => { - const query = User.find({}).sort('age'); - query.data[0].should.eql(data[2]); - query.data[1].should.eql(data[0]); - query.data[2].should.eql(data[1]); - return data; - }).map(item => User.removeById(item._id))); - - it('sort() - object', () => Loop.insert([ - {age: {age: 15}}, - {age: {age: 35}}, - {age: {age: 10}} - ]).then(data => { - const query = Loop.find({}).sort('age', { age: 1 }); - query.data[0].should.eql(data[2]); - query.data[1].should.eql(data[0]); - query.data[2].should.eql(data[1]); - return data; - }).map(item => Loop.removeById(item._id))); - - it('sort() - descending', () => User.insert([ - {age: 15}, - {age: 35}, - {age: 10} - ]).then(data => { - const query = User.find({}).sort('age', -1); - query.data[0].should.eql(data[1]); - query.data[1].should.eql(data[0]); - query.data[2].should.eql(data[2]); - return data; - }).map(item => User.removeById(item._id))); - - it('sort() - multi', () => User.insert([ - {age: 15, name: 'A'}, - {age: 30, name: 'B'}, - {age: 20, name: 'C'}, - {age: 20, name: 'D'} - ]).then(data => { - const query = User.find({}).sort('age name'); - query.data[0].should.eql(data[0]); - query.data[1].should.eql(data[2]); - query.data[2].should.eql(data[3]); - query.data[3].should.eql(data[1]); - return data; - }).map(item => User.removeById(item._id))); - - it('map()', () => User.insert(Array(5).fill({})).then(data => { - let num = 0; - - const d1 = User.find({}).map((item, i) => { - i.should.eql(num++); - return item._id; - }); - - const d2 = data.map(item => item._id); - - d1.should.eql(d2); - - return data; - }).map(item => User.removeById(item._id))); - - it('reduce()', () => User.insert([ - {name: 'A'}, - {name: 'B'}, - {name: 'C'} - ]).then(data => { - let num = 1; - - const sum = User.find({}).reduce((sum, item, i) => { - i.should.eql(num++); - return {name: sum.name + item.name}; - }); - - sum.name.should.eql('ABC'); - - return data; - }).map(item => User.removeById(item._id))); - - it('reduce() - initial', () => User.insert([ - {name: 'A'}, - {name: 'B'}, - {name: 'C'} - ]).then(data => { - let num = 0; - - const sum = User.find({}).reduce((sum, item, i) => { - i.should.eql(num++); - return sum + item.name; - }, '_'); - - sum.should.eql('_ABC'); - - return data; - }).map(item => User.removeById(item._id))); - - it('reduceRight()', () => User.insert([ - {name: 'A'}, - {name: 'B'}, - {name: 'C'} - ]).then(data => { - let num = 1; - - const sum = User.find({}).reduceRight((sum, item, i) => { - i.should.eql(num--); - return {name: sum.name + item.name}; - }); - - sum.name.should.eql('CBA'); - - return data; - }).map(item => User.removeById(item._id))); - - it('reduceRight() - initial', () => User.insert([ - {name: 'A'}, - {name: 'B'}, - {name: 'C'} - ]).then(data => { - let num = 2; - - const sum = User.find({}).reduceRight((sum, item, i) => { - i.should.eql(num--); - return sum + item.name; - }, '_'); - - sum.should.eql('_CBA'); - - return data; - }).map(item => User.removeById(item._id))); - - it('filter()', () => User.insert([ - {age: 10}, - {age: 20}, - {age: 30}, - {age: 40} - ]).then(data => { - let num = 0; - - const query = User.find({}).filter((data, i) => { - i.should.eql(num++); - return data.age > 20; - }); - - query.data.should.eql(data.slice(2)); - - return data; - }).map(item => User.removeById(item._id))); - - it('every()', () => User.insert([ - {age: 10}, - {age: 20}, - {age: 30}, - {age: 40} - ]).then(data => { - let num = 0; - - User.find({}).every((data, i) => { - i.should.eql(num++); - return data.age; - }).should.be.true; - - User.find({}).every((data, i) => data.age > 10).should.be.false; - - return data; - }).map(item => User.removeById(item._id))); - - it('some()', () => User.insert([ - {age: 10}, - {age: 20}, - {age: 30}, - {age: 40} - ]).then(data => { - let num = 0; - - User.find({}).some((data, i) => data.age > 10).should.be.true; - - User.find({}).some((data, i) => { - i.should.eql(num++); - return data.age < 0; - }).should.be.false; - - return data; - }).map(item => User.removeById(item._id))); - - it('update()', () => User.insert([ - {age: 10}, - {age: 20}, - {age: 30}, - {age: 20}, - {age: 40} - ]).then(data => User.find({age: 20}).update({name: 'A'}).then(updated => { - updated[0]._id.should.eql(data[1]._id); - updated[1]._id.should.eql(data[3]._id); - updated[0].name.should.eql('A'); - updated[1].name.should.eql('A'); - return data; - })).map(item => User.removeById(item._id))); - - it('replace()', () => User.insert([ - {age: 10}, - {age: 20}, - {age: 30}, - {age: 20}, - {age: 40} - ]).then(data => User.find({age: 20}).replace({name: 'A'}).then(updated => { - updated[0]._id.should.eql(data[1]._id); - updated[1]._id.should.eql(data[3]._id); - updated[0].name.should.eql('A'); - updated[1].name.should.eql('A'); - return data; - })).map(item => User.removeById(item._id))); - - it('remove()', () => User.insert([ - {age: 10}, - {age: 20}, - {age: 30}, - {age: 20}, - {age: 40} - ]).then(data => User.find({age: 20}).remove().then(removed => { - should.not.exist(User.findById(data[1]._id)); - should.not.exist(User.findById(data[3]._id)); - return [data[0], data[2], data[4]]; - })).map(item => User.removeById(item._id))); - - it('populate() - object', () => { - let user, comment; - - return User.insert({}).then(user_ => { - user = user_; - - return Comment.insert({ - author: user._id - }); - }).then(comment_ => { - comment = comment_; - return Comment.find({}).populate('author'); - }).then(result => { - result.first().author.should.eql(user); - - return Promise.all([ - User.removeById(user._id), - Comment.removeById(comment._id) - ]); - }); - }); - - it('populate() - array', () => { - let comments, user; - - return Comment.insert([ - {content: 'foo'}, - {content: 'bar'}, - {content: 'baz'}, - {content: 'ha'} - ]).then(comments_ => { - comments = comments_; - - return User.insert({ - comments: comments.map(item => item._id) - }); - }).then(user_ => { - user = user_; - return User.populate('comments'); - }).then(result => { - result.first().comments.toArray().should.eql(comments); - - return Promise.all([ - User.removeById(user._id), - Comment.removeById(comments[0]._id), - Comment.removeById(comments[1]._id), - Comment.removeById(comments[2]._id), - Comment.removeById(comments[3]._id) - ]); - }); - }); - - it('populate() - array expr - string', () => { - let user, comment; - - return User.insert({}).then(user_ => { - user = user_; - - return Comment.insert({ - author: user._id - }); - }).then(comment_ => { - comment = comment_; - return Comment.find({}).populate(['author']); - }).then(result => { - result.first().author.should.eql(user); - - return Promise.all([ - User.removeById(user._id), - Comment.removeById(comment._id) - ]); - }); - }); - - it('populate() - array expr - object', () => { - let user, comment; - - return User.insert({}).then(user_ => { - user = user_; - - return Comment.insert({ - author: user._id - }); - }).then(comment_ => { - comment = comment_; - return Comment.find({}).populate([{ path: 'author' }]); - }).then(result => { - result.first().author.should.eql(user); - - return Promise.all([ - User.removeById(user._id), - Comment.removeById(comment._id) - ]); - }); - }); - - it('populate() - path is required', () => { - try { - Comment.find({}).populate({}); - } catch (err) { - err.message.should.eql('path is required'); - } - }); -}); diff --git a/media/scripts/schema.ts b/media/scripts/schema.ts deleted file mode 100644 index 5e90e17c..00000000 --- a/media/scripts/schema.ts +++ /dev/null @@ -1,162 +0,0 @@ -import chai from 'chai'; -const should = chai.should(); // eslint-disable-line -import Database from '../../dist/database'; - -describe('Schema', () => { - const Schema = Database.Schema; - - it('add()', () => { - const schema = new Schema(); - - schema.add({ - str1: String, - str2: {type: String}, - num1: Number, - num2: {type: Number}, - bool1: Boolean, - bool2: {type: Boolean}, - date1: Date, - date2: {type: Date}, - arr1: [], - arr2: [String], - arr3: [{type: String}], - obj1: Object, - obj2: { - foo: String, - bar: { - baz: {type: Number} - } - }, - id: {type: Schema.Types.CUID, required: true} - }); - - // string - schema.paths.str1.should.be.an.instanceOf(Schema.Types.String); - schema.paths.str2.should.be.an.instanceOf(Schema.Types.String); - - // number - schema.paths.num1.should.be.an.instanceOf(Schema.Types.Number); - schema.paths.num2.should.be.an.instanceOf(Schema.Types.Number); - - // boolean - schema.paths.bool1.should.be.an.instanceOf(Schema.Types.Boolean); - schema.paths.bool2.should.be.an.instanceOf(Schema.Types.Boolean); - - // date - schema.paths.date1.should.be.an.instanceOf(Schema.Types.Date); - schema.paths.date2.should.be.an.instanceOf(Schema.Types.Date); - - // array - schema.paths.arr1.should.be.an.instanceOf(Schema.Types.Array); - // @ts-ignore - schema.paths.arr1.child.should.be.an.instanceOf(Schema.Types.Mixed); - schema.paths.arr2.should.be.an.instanceOf(Schema.Types.Array); - // @ts-ignore - schema.paths.arr2.child.should.be.an.instanceOf(Schema.Types.String); - schema.paths.arr3.should.be.an.instanceOf(Schema.Types.Array); - // @ts-ignore - schema.paths.arr3.child.should.be.an.instanceOf(Schema.Types.String); - - // object - schema.paths.obj1.should.be.an.instanceOf(Schema.Types.Object); - schema.paths.obj2.should.be.an.instanceOf(Schema.Types.Object); - schema.paths['obj2.foo'].should.be.an.instanceOf(Schema.Types.String); - schema.paths['obj2.bar'].should.be.an.instanceOf(Schema.Types.Object); - schema.paths['obj2.bar.baz'].should.be.an.instanceOf(Schema.Types.Number); - - // id - schema.paths.id.should.be.an.instanceOf(Schema.Types.CUID); - schema.paths.id.options.required.should.be.true; - }); - - it('virtual() - without getter', () => { - const schema = new Schema(); - - schema.virtual('test'); - schema.paths.test.should.be.an.instanceOf(Schema.Types.Virtual); - }); - - it('virtual() - with getter', () => { - const schema = new Schema(); - - schema.virtual('test', () => {}); - - schema.paths.test.should.be - .an.instanceOf(Schema.Types.Virtual) - .have.property('getter'); - }); - - it('pre()', () => { - const schema = new Schema(); - - // save - schema.pre('save', () => {}); - - schema.hooks.pre.save.should.have.length(1); - - // remove - schema.pre('remove', () => {}); - - schema.hooks.pre.remove.should.have.length(1); - - // incompatible type - // @ts-expect-error - (() => schema.pre('wtf', () => {})).should.to.throw(TypeError, 'Hook type must be `save` or `remove`!'); - - // hook is not a function - // @ts-expect-error - (() => schema.pre('save', {})).should.to.throw(TypeError, 'Hook must be a function!'); - }); - - it('post()', () => { - const schema = new Schema(); - - // save - schema.post('save', () => {}); - - schema.hooks.post.save.should.have.length(1); - - // remove - schema.post('remove', () => {}); - - schema.hooks.post.remove.should.have.length(1); - - // incompatible type - // @ts-expect-error - (() => schema.post('wtf', () => {})).should.throw(TypeError, 'Hook type must be `save` or `remove`!'); - - // hook is not a function - // @ts-expect-error - (() => schema.post('save', {})).should.to.throw(TypeError, 'Hook must be a function!'); - }); - - it('method()', () => { - const schema = new Schema(); - - schema.method('test', () => {}); - - schema.methods.test.should.exist; - - // without name - schema.method.should.to.throw(TypeError, 'Method name is required!'); - - // without function - // @ts-expect-error - (() => schema.method('wtf', {})).should.to.throw(TypeError, 'Instance method must be a function!'); - }); - - it('static()', () => { - const schema = new Schema(); - - schema.static('test', () => {}); - - schema.statics.test.should.exist; - - // without name - schema.static.should.to.throw(TypeError, 'Method name is required!'); - - // without function - // @ts-expect-error - (() => schema.static('wtf', {})).should.to.throw(TypeError, 'Static method must be a function!'); - }); -}); diff --git a/media/scripts/schematype.ts b/media/scripts/schematype.ts deleted file mode 100644 index 39abb55f..00000000 --- a/media/scripts/schematype.ts +++ /dev/null @@ -1,144 +0,0 @@ -import chai from 'chai'; -const should = chai.should(); // eslint-disable-line -import ValidationError from '../../dist/error/validation'; -import SchemaType from '../../dist/schematype'; - -describe('SchemaType', () => { - const type = new SchemaType('test'); - - it('cast()', () => { - (type.cast(123) as number).should.eql(123); - }); - - it('cast() - default', () => { - const type = new SchemaType('test', {default: 'foo'}); - (type.cast() as string).should.eql('foo'); - }); - - it('cast() - default - function', () => { - const type = new SchemaType('test', {default: () => 'foo'}); - (type.cast() as string).should.eql('foo'); - }); - - it('validate()', () => { - (type.validate(123) as number).should.eql(123); - }); - - it('validate() - required', () => { - const type = new SchemaType('test', {required: true}); - - type.validate.bind(type).should.to.throw(ValidationError, '`test` is required!'); - }); - - it('compare()', () => { - type.compare(2, 1).should.eql(1); - type.compare(1, 2).should.eql(-1); - type.compare(1, 1).should.eql(0); - }); - - it('parse()', () => { - type.parse(123).should.eql(123); - }); - - it('value()', () => { - type.value(123).should.eql(123); - }); - - it('match()', () => { - type.match(1, 1).should.be.true; - type.match(1, '1').should.be.false; - }); - - it('q$exist', () => { - // array - type.q$exist(['foo'], true).should.be.true; - type.q$exist([], true).should.be.true; - type.q$exist(['foo'], false).should.be.false; - type.q$exist([], false).should.be.false; - - // boolean - type.q$exist(true, true).should.be.true; - type.q$exist(false, true).should.be.true; - type.q$exist(true, false).should.be.false; - type.q$exist(false, false).should.be.false; - - // number - type.q$exist(1, true).should.be.true; - type.q$exist(0, true).should.be.true; - type.q$exist(1, false).should.be.false; - type.q$exist(0, false).should.be.false; - - // object - type.q$exist({length: 1}, true).should.be.true; - type.q$exist({}, true).should.be.true; - type.q$exist({length: 1}, false).should.be.false; - type.q$exist({}, false).should.be.false; - - // string - type.q$exist('test', true).should.be.true; - type.q$exist('', true).should.be.true; - type.q$exist('test', false).should.be.false; - type.q$exist('', false).should.be.false; - - // undefined - type.q$exist(null, true).should.be.false; - type.q$exist(undefined, true).should.be.false; - type.q$exist(null, false).should.be.true; - type.q$exist(undefined, false).should.be.true; - }); - - it('q$ne', () => { - type.q$ne(1, 1).should.be.false; - type.q$ne(1, '1').should.be.true; - }); - - it('q$lt', () => { - type.q$lt(1, 2).should.be.true; - type.q$lt(1, 1).should.be.false; - type.q$lt(1, 0).should.be.false; - }); - - it('q$lte', () => { - type.q$lte(1, 2).should.be.true; - type.q$lte(1, 1).should.be.true; - type.q$lte(1, 0).should.be.false; - }); - - it('q$gt', () => { - type.q$gt(1, 2).should.be.false; - type.q$gt(1, 1).should.be.false; - type.q$gt(1, 0).should.be.true; - }); - - it('q$gte', () => { - type.q$gte(1, 2).should.be.false; - type.q$gte(1, 1).should.be.true; - type.q$gte(1, 0).should.be.true; - }); - - it('q$in', () => { - type.q$in(1, [0, 1, 2]).should.be.true; - type.q$in(1, ['0', '1', '2']).should.be.false; - }); - - it('q$nin', () => { - type.q$nin(1, [0, 2, 4]).should.be.true; - type.q$nin(1, [0, 1, 2]).should.be.false; - }); - - it('u$set', () => { - type.u$set(1, 1).should.eql(1); - }); - - it('u$unset', () => { - should.not.exist(type.u$unset(1, true)); - (type.u$unset(1, false) as number).should.eql(1); - }); - - it('u$rename', () => { - const obj = {a: 1}; - should.not.exist(type.u$rename(1, 'b', obj)); - // @ts-ignore - obj.b.should.eql(1); - }); -}); diff --git a/media/scripts/types/array.ts b/media/scripts/types/array.ts deleted file mode 100644 index 61cd52ba..00000000 --- a/media/scripts/types/array.ts +++ /dev/null @@ -1,179 +0,0 @@ -import chai from 'chai'; -const should = chai.should(); // eslint-disable-line -import ValidationError from '../../../dist/error/validation'; -import SchemaTypeArray from '../../../dist/types/array'; -import SchemaTypeString from '../../../dist/types/string'; -import SchemaTypeDate from '../../../dist/types/date'; -import SchemaTypeBoolean from '../../../dist/types/boolean'; - -describe('SchemaTypeArray', () => { - const type = new SchemaTypeArray('test'); - - it('cast()', () => { - type.cast('foo').should.eql(['foo']); - type.cast([]).should.eql([]); - type.cast([1, 2, 3]).should.eql([1, 2, 3]); - (type.cast() as any[]).should.eql([]); - }); - - it('cast() - default', () => { - const type = new SchemaTypeArray('test', {default: [1, 2, 3]}); - (type.cast() as any[]).should.eql([1, 2, 3]); - }); - - it('cast() - child', () => { - const type = new SchemaTypeArray('test', {child: new SchemaTypeString()}); - type.cast([1, 2, 3]).should.eql(['1', '2', '3']); - }); - - function shouldThrowError(value) { - (() => type.validate(value)).should.to.throw(ValidationError, `\`${value}\` is not an array!`); - } - - it('validate()', () => { - type.validate([]).should.eql([]); - type.validate([1, 2, 3]).should.eql([1, 2, 3]); - shouldThrowError(''); - shouldThrowError('foo'); - shouldThrowError(0); - shouldThrowError(1); - shouldThrowError({}); - shouldThrowError(true); - }); - - it('validate() - required', () => { - const type = new SchemaTypeArray('test', {required: true}); - - type.validate.bind(type).should.to.throw(ValidationError, '`test` is required!'); - }); - - it('validate() - child', () => { - const type = new SchemaTypeArray('test', {child: new SchemaTypeString()}); - - (() => type.validate([1, 2, 3])).should.to.throw(ValidationError, '`1` is not a string!'); - }); - - it('compare()', () => { - type.compare([1, 2, 3], [1, 2, 4]).should.eql(-1); - type.compare([1, 2, 3], [1, 2, 3]).should.eql(0); - type.compare([1, 2, 3], [1, 2, 2]).should.eql(1); - type.compare([1, 2, 3, 4], [1, 2, 3]).should.eql(1); - type.compare(undefined, []).should.eql(-1); - type.compare([]).should.eql(1); - type.compare().should.eql(0); - }); - - it('compare() - child', () => { - const type = new SchemaTypeArray('test', {child: new SchemaTypeDate()}); - type.compare([new Date(1e8), new Date(1e8 + 1)], [new Date(1e8), new Date(1e8 + 2)]) - .should.eql(-1); - }); - - it('parse()', () => { - type.parse([1, 2, 3]).should.eql([1, 2, 3]); - should.not.exist(type.parse()); - }); - - it('parse() - child', () => { - const type = new SchemaTypeArray('test', {child: new SchemaTypeBoolean()}); - type.parse([0, 1, 0]).should.eql([false, true, false]); - }); - - it('value()', () => { - type.value([1, 2, 3]).should.eql([1, 2, 3]); - should.not.exist(type.value()); - }); - - it('value() - child', () => { - const type = new SchemaTypeArray('test', {child: new SchemaTypeBoolean()}); - type.value([true, false, true]).should.eql([1, 0, 1]); - }); - - it('match()', () => { - type.match([1, 2, 3], [1, 2, 3]).should.be.true; - type.match([1, 2, 3], ['1', '2', '3']).should.be.false; - type.match([1, 2, 3], [1, 2, 3, 4]).should.be.false; - type.match(undefined, []).should.be.false; - type.match(undefined, undefined).should.be.true; - }); - - it('match() - child', () => { - const type = new SchemaTypeArray('test', {child: new SchemaTypeDate()}); - type.match([new Date(2014, 1, 1)], [new Date(2014, 1, 1)]).should.be.true; - type.match([new Date(2014, 1, 2)], [new Date(2014, 1, 1)]).should.be.false; - }); - - it('q$size()', () => { - type.q$size([1, 2, 3], 3).should.be.true; - type.q$size([1, 2], 3).should.be.false; - type.q$size([], 0).should.be.true; - type.q$size(undefined, 0).should.be.true; - type.q$size(undefined, 3).should.be.false; - }); - - it('q$in()', () => { - type.q$in([1, 2, 3], [1, 4]).should.be.true; - type.q$in([1, 2, 3], [4, 5]).should.be.false; - type.q$in(undefined, [1, 2]).should.be.false; - }); - - it('q$nin()', () => { - type.q$nin([1, 2, 3], [1, 4]).should.be.false; - type.q$nin([1, 2, 3], [4, 5]).should.be.true; - type.q$nin(undefined, [1, 2]).should.be.true; - }); - - it('q$all()', () => { - type.q$all([1, 2, 3], [1, 2]).should.be.true; - type.q$all([1, 2, 3], [1, 4]).should.be.false; - type.q$all([1, 2, 3], [4, 5, 6]).should.be.false; - type.q$all(undefined, [1, 2]).should.be.false; - }); - - it('u$push()', () => { - type.u$push([1, 2, 3], 4).should.eql([1, 2, 3, 4]); - type.u$push([1, 2, 3], [4, 5]).should.eql([1, 2, 3, 4, 5]); - type.u$push(undefined, 4).should.eql([4]); - type.u$push(undefined, [4, 5]).should.eql([4, 5]); - }); - - it('u$unshift()', () => { - type.u$unshift([1, 2, 3], 0).should.eql([0, 1, 2, 3]); - type.u$unshift([1, 2, 3], [-1, 0]).should.eql([-1, 0, 1, 2, 3]); - type.u$unshift(undefined, 0).should.eql([0]); - type.u$unshift(undefined, [0, 1]).should.eql([0, 1]); - }); - - it('u$pull()', () => { - type.u$pull([1, 2, 3, 3, 4], 3).should.eql([1, 2, 4]); - type.u$pull([1, 1, 2, 3, 3], [1, 3]).should.eql([2]); - should.not.exist(type.u$pull(undefined, 1)); - }); - - it('u$shift()', () => { - type.u$shift([1, 2, 3], true).should.eql([2, 3]); - type.u$shift([1, 2, 3], 2).should.eql([3]); - type.u$shift([1, 2, 3], false).should.eql([1, 2, 3]); - type.u$shift([1, 2, 3], 0).should.eql([1, 2, 3]); - type.u$shift([1, 2, 3], -1).should.eql([1, 2]); - should.not.exist(type.u$shift(undefined, true)); - }); - - it('u$pop()', () => { - type.u$pop([1, 2, 3], true).should.eql([1, 2]); - type.u$pop([1, 2, 3], 2).should.eql([1]); - type.u$pop([1, 2, 3], false).should.eql([1, 2, 3]); - type.u$pop([1, 2, 3], 0).should.eql([1, 2, 3]); - type.u$pop([1, 2, 3], -1).should.eql([2, 3]); - should.not.exist(type.u$pop(undefined, true)); - }); - - it('u$addToSet()', () => { - type.u$addToSet([1, 2, 3], 4).should.eql([1, 2, 3, 4]); - type.u$addToSet([1, 2, 3], 2).should.eql([1, 2, 3]); - type.u$addToSet([1, 2, 3], [4, 5]).should.eql([1, 2, 3, 4, 5]); - type.u$addToSet([1, 2, 3], [2, 4, 6]).should.eql([1, 2, 3, 4, 6]); - type.u$addToSet(undefined, 1).should.eql([1]); - type.u$addToSet(undefined, [1, 2, 3]).should.eql([1, 2, 3]); - }); -}); diff --git a/media/scripts/types/boolean.ts b/media/scripts/types/boolean.ts deleted file mode 100644 index bf84920c..00000000 --- a/media/scripts/types/boolean.ts +++ /dev/null @@ -1,59 +0,0 @@ -import chai from 'chai'; -const should = chai.should(); // eslint-disable-line -import ValidationError from '../../../dist/error/validation'; -import SchemaTypeBoolean from '../../../dist/types/boolean'; - -describe('SchemaTypeBoolean', () => { - const type = new SchemaTypeBoolean('test'); - - it('cast()', () => { - type.cast(true).should.be.true; - type.cast(false).should.be.false; - - type.cast(0).should.be.false; - type.cast('0').should.be.false; - type.cast(1).should.be.true; - type.cast('1').should.be.true; - - type.cast('').should.be.false; - type.cast('false').should.be.false; - type.cast('true').should.be.true; - type.cast('foo').should.be.true; - }); - - it('cast() - default', () => { - const type = new SchemaTypeBoolean('test', {default: true}); - type.cast().should.be.true; - }); - - function shouldThrowError(value) { - (() => type.validate(value)).should.to.throw(ValidationError, `\`${value}\` is not a boolean!`); - } - - it('validate()', () => { - type.validate(true).should.be.true; - type.validate(false).should.be.false; - shouldThrowError(1); - shouldThrowError(0); - shouldThrowError(''); - shouldThrowError('foo'); - shouldThrowError([]); - shouldThrowError({}); - }); - - it('validate() - required', () => { - const type = new SchemaTypeBoolean('test', {required: true}); - - type.validate.bind(type).should.to.throw(ValidationError, '`test` is required!'); - }); - - it('parse()', () => { - type.parse(1).should.be.true; - type.parse(0).should.be.false; - }); - - it('value()', () => { - type.value(true).should.eql(1); - type.value(false).should.eql(0); - }); -}); diff --git a/media/scripts/types/buffer.ts b/media/scripts/types/buffer.ts deleted file mode 100644 index 90ee44c9..00000000 --- a/media/scripts/types/buffer.ts +++ /dev/null @@ -1,91 +0,0 @@ -import chai from 'chai'; -const should = chai.should(); // eslint-disable-line -import ValidationError from '../../../dist/error/validation'; -import SchemaTypeBuffer from '../../../dist/types/buffer'; - -describe('SchemaTypeBuffer', () => { - const type = new SchemaTypeBuffer('test'); - - it('cast()', () => { - const buf = Buffer.from([97, 98, 99]); - - type.cast(buf).should.eql(buf); - type.cast(buf.toString('hex')).should.eql(buf); - type.cast([97, 98, 99]).should.eql(buf); - }); - - it('cast() - custom encoding', () => { - const buf = Buffer.from([97, 98, 99]); - const type = new SchemaTypeBuffer('test', {encoding: 'base64'}); - - type.cast(buf.toString('base64')).should.eql(buf); - }); - - it('cast() - default', () => { - const buf = Buffer.from([97, 98, 99]); - const type = new SchemaTypeBuffer('test', {default: buf}); - - (type.cast() as Buffer).should.eql(buf); - }); - - function shouldThrowError(value) { - (() => type.validate(value)).should.to.throw(ValidationError, `\`${value}\` is not a valid buffer!`); - } - - it('validate()', () => { - type.validate(Buffer.from([97, 98, 99])).should.eql(Buffer.from([97, 98, 99])); - shouldThrowError(1); - shouldThrowError('foo'); - shouldThrowError([]); - shouldThrowError(true); - shouldThrowError({}); - }); - - it('validate() - required', () => { - const type = new SchemaTypeBuffer('test', {required: true}); - - type.validate.bind(type).should.to.throw(ValidationError, '`test` is required!'); - }); - - it('match()', () => { - type.match(Buffer.from([97, 98, 99]), Buffer.from([97, 98, 99])).should.be.true; - type.match(Buffer.from([97, 98, 99]), Buffer.from([97, 98, 100])).should.be.false; - // @ts-ignore - type.match(undefined, Buffer.from([97, 98, 99])).should.be.false; - // @ts-ignore - type.match(undefined, undefined).should.be.true; - }); - - it('compare()', () => { - type.compare(Buffer.from([97, 98, 99]), Buffer.from([97, 98, 99])).should.eql(0); - type.compare(Buffer.from([97, 98, 99]), Buffer.from([97, 98, 100])).should.lt(0); - type.compare(Buffer.from([97, 98, 99]), Buffer.from([97, 98, 98])).should.gt(0); - type.compare(Buffer.from([97, 98, 99])).should.eql(1); - type.compare(undefined, Buffer.from([97, 98, 99])).should.eql(-1); - type.compare().should.eql(0); - }); - - it('parse()', () => { - const buf = Buffer.from([97, 98, 99]); - type.parse(buf.toString('hex')).should.eql(buf); - should.not.exist(type.parse()); - }); - - it('parse() - custom encoding', () => { - const type = new SchemaTypeBuffer('name', {encoding: 'base64'}); - const buf = Buffer.from([97, 98, 99]); - type.parse(buf.toString('base64')).should.eql(buf); - }); - - it('value()', () => { - const buf = Buffer.from([97, 98, 99]); - type.value(buf).should.eql(buf.toString('hex')); - should.not.exist(type.value()); - }); - - it('value() - custom encoding', () => { - const type = new SchemaTypeBuffer('name', {encoding: 'base64'}); - const buf = Buffer.from([97, 98, 99]); - type.value(buf).should.eql(buf.toString('base64')); - }); -}); diff --git a/media/scripts/types/cuid.ts b/media/scripts/types/cuid.ts deleted file mode 100644 index 86a4aa9e..00000000 --- a/media/scripts/types/cuid.ts +++ /dev/null @@ -1,26 +0,0 @@ -import chai from 'chai'; -const should = chai.should(); // eslint-disable-line -import { nanoid } from 'nanoid'; -import ValidationError from '../../../dist/error/validation'; -import SchemaTypeCUID from '../../../dist/types/cuid'; - -describe('SchemaTypeCUID', () => { - const type = new SchemaTypeCUID('test'); - - it('cast()', () => { - type.cast('foo').should.eql('foo'); - should.not.exist(type.cast()); - }); - - it('cast() - required', () => { - const type = new SchemaTypeCUID('test', {required: true}); - type.cast().should.exist; - }); - - it('validate()', () => { - const id = 'cuid' + nanoid(); - type.validate(id).should.eql(id); - - (() => type.validate('foo')).should.to.throw(ValidationError, '`foo` is not a valid CUID'); - }); -}); diff --git a/media/scripts/types/date.ts b/media/scripts/types/date.ts deleted file mode 100644 index 49a55ca3..00000000 --- a/media/scripts/types/date.ts +++ /dev/null @@ -1,97 +0,0 @@ -import chai from 'chai'; -const should = chai.should(); // eslint-disable-line -import ValidationError from '../../../dist/error/validation'; -import SchemaTypeDate from '../../../dist/types/date'; - -describe('SchemaTypeDate', () => { - const type = new SchemaTypeDate('test'); - - it('cast()', () => { - type.cast(new Date(2014, 1, 1)).should.eql(new Date(2014, 1, 1)); - type.cast(1e8).should.eql(new Date(1e8)); - type.cast('2014-11-03T07:45:41.237Z').should.eql(new Date('2014-11-03T07:45:41.237Z')); - }); - - it('cast() - default', () => { - const date = new Date(); - const type = new SchemaTypeDate('test', {default: date}); - - (type.cast() as Date).should.eql(date); - }); - - function shouldThrowError(value) { - (() => type.validate(value)).should.to.throw(ValidationError, `\`${value}\` is not a valid date!`); - } - - it('validate()', () => { - type.validate(new Date(2014, 1, 1)).should.eql(new Date(2014, 1, 1)); - shouldThrowError(1); - shouldThrowError('foo'); - shouldThrowError([]); - shouldThrowError(true); - shouldThrowError({}); - shouldThrowError(new Date('foo')); - }); - - it('validate() - required', () => { - const type = new SchemaTypeDate('test', {required: true}); - - type.validate.bind(type).should.to.throw(ValidationError, '`test` is required!'); - }); - - it('match()', () => { - type.match(new Date(2014, 1, 1), new Date(2014, 1, 1)).should.be.true; - type.match(new Date(2014, 1, 1), new Date(2014, 1, 2)).should.be.false; - // @ts-ignore - type.match(undefined, new Date()).should.be.false; - // @ts-ignore - type.match(undefined, undefined).should.be.true; - }); - - it('compare()', () => { - type.compare(new Date(2014, 1, 3), new Date(2014, 1, 2)).should.gt(0); - type.compare(new Date(2014, 1, 1), new Date(2014, 1, 2)).should.lt(0); - type.compare(new Date(2014, 1, 2), new Date(2014, 1, 2)).should.eql(0); - type.compare(new Date()).should.eql(1); - type.compare(undefined, new Date()).should.eql(-1); - type.compare().should.eql(0); - }); - - it('parse()', () => { - type.parse('2014-11-03T07:45:41.237Z').should.eql(new Date('2014-11-03T07:45:41.237Z')); - should.not.exist(type.parse()); - }); - - it('value()', () => { - type.value(new Date('2014-11-03T07:45:41.237Z')).should.eql('2014-11-03T07:45:41.237Z'); - should.not.exist(type.value()); - }); - - it('q$day()', () => { - type.q$day(new Date(2014, 1, 1), 1).should.be.true; - type.q$day(new Date(2014, 1, 1), 5).should.be.false; - type.q$day(undefined, 1).should.be.false; - }); - - it('q$month()', () => { - type.q$month(new Date(2014, 1, 1), 1).should.be.true; - type.q$month(new Date(2014, 1, 1), 5).should.be.false; - type.q$month(undefined, 1).should.be.false; - }); - - it('q$year()', () => { - type.q$year(new Date(2014, 1, 1), 2014).should.be.true; - type.q$year(new Date(2014, 1, 1), 1999).should.be.false; - type.q$year(undefined, 2014).should.be.false; - }); - - it('u$inc()', () => { - type.u$inc(new Date(1e8), 1).should.eql(new Date(1e8 + 1)); - should.not.exist(undefined, '1'); - }); - - it('u$dec()', () => { - type.u$dec(new Date(1e8), 1).should.eql(new Date(1e8 - 1)); - should.not.exist(undefined, '1'); - }); -}); diff --git a/media/scripts/types/enum.ts b/media/scripts/types/enum.ts deleted file mode 100644 index 7804322b..00000000 --- a/media/scripts/types/enum.ts +++ /dev/null @@ -1,20 +0,0 @@ -import chai from 'chai'; -const should = chai.should(); // eslint-disable-line -import ValidationError from '../../../dist/error/validation'; -import SchemaTypeEnum from '../../../dist/types/enum'; - -describe('SchemaTypeEnum', () => { - it('validate()', () => { - const type = new SchemaTypeEnum('test', {elements: ['foo', 'bar', 'baz']}); - - (type.validate('foo') as string).should.eql('foo'); - - (() => type.validate('wat')).should.to.throw(ValidationError, 'The value must be one of foo, bar, baz'); - }); - - it('validate() - required', () => { - const type = new SchemaTypeEnum('test', {required: true}); - - type.validate.bind(type).should.to.throw(ValidationError, '`test` is required!'); - }); -}); diff --git a/media/scripts/types/integer.ts b/media/scripts/types/integer.ts deleted file mode 100644 index ffe341f2..00000000 --- a/media/scripts/types/integer.ts +++ /dev/null @@ -1,45 +0,0 @@ -import chai from 'chai'; -const should = chai.should(); // eslint-disable-line -import ValidationError from '../../../dist/error/validation'; -import SchemaTypeInteger from '../../../dist/types/integer'; - -describe('SchemaTypeInteger', () => { - const type = new SchemaTypeInteger('test'); - - it('cast()', () => { - type.cast(0).should.eql(0); - type.cast(3.14).should.eql(3); - type.cast('0').should.eql(0); - type.cast('3.14').should.eql(3); - type.cast('084').should.eql(84); - type.cast(true).should.eql(1); - type.cast(false).should.eql(0); - }); - - it('cast() - default', () => { - const type = new SchemaTypeInteger('test', {default: 3}); - type.cast().should.eql(3); - }); - - function shouldThrowError(value) { - (() => type.validate(value)).should.to.throw(ValidationError, `\`${value}\` is not a number!`); - } - - it('validate()', () => { - type.validate(1).should.eql(1); - type.validate(0).should.eql(0); - shouldThrowError(NaN); - shouldThrowError([]); - shouldThrowError(true); - shouldThrowError(false); - shouldThrowError({}); - - (() => type.validate(3.14)).should.to.throw(ValidationError, '`3.14` is not an integer!'); - }); - - it('validate() - required', () => { - const type = new SchemaTypeInteger('test', {required: true}); - - type.validate.bind(type).should.to.throw(ValidationError, '`test` is required!'); - }); -}); diff --git a/media/scripts/types/number.ts b/media/scripts/types/number.ts deleted file mode 100644 index 3dd6003b..00000000 --- a/media/scripts/types/number.ts +++ /dev/null @@ -1,78 +0,0 @@ -import chai from 'chai'; -const should = chai.should(); // eslint-disable-line -import ValidationError from '../../../dist/error/validation'; -import SchemaTypeNumber from '../../../dist/types/number'; - -describe('SchemaTypeNumber', () => { - const type = new SchemaTypeNumber('type'); - - it('cast()', () => { - type.cast(0).should.eql(0); - type.cast(1).should.eql(1); - type.cast('0').should.eql(0); - type.cast('1').should.eql(1); - type.cast(true).should.eql(1); - type.cast(false).should.eql(0); - }); - - it('cast() - default', () => { - const type = new SchemaTypeNumber('type', {default: 42}); - (type.cast() as number).should.eql(42); - }); - - function shouldThrowError(value) { - (() => type.validate(value)).should.to.throw(ValidationError, `\`${value}\` is not a number!`); - } - - it('validate()', () => { - type.validate(1).should.eql(1); - type.validate(0).should.eql(0); - shouldThrowError(NaN); - shouldThrowError(''); - shouldThrowError([]); - shouldThrowError(true); - shouldThrowError(false); - shouldThrowError({}); - }); - - it('validate() - required', () => { - const type = new SchemaTypeNumber('test', {required: true}); - - type.validate.bind(type).should.to.throw(ValidationError, '`test` is required!'); - }); - - it('u$inc()', () => { - type.u$inc(2, 3).should.eql(5); - type.u$inc(undefined, 3).should.eql(3); - }); - - it('u$dec()', () => { - type.u$dec(2, 3).should.eql(-1); - type.u$dec(undefined, 3).should.eql(-3); - }); - - it('u$mul()', () => { - type.u$mul(2, 3).should.eql(6); - type.u$mul(undefined, 3).should.eql(0); - }); - - it('u$div()', () => { - type.u$div(10, 5).should.eql(2); - type.u$div(undefined, 5).should.eql(0); - }); - - it('u$mod()', () => { - type.u$mod(13, 5).should.eql(3); - type.u$mod(undefined, 5).should.eql(0); - }); - - it('u$max()', () => { - type.u$max(20, 50).should.eql(50); - type.u$max(70, 50).should.eql(70); - }); - - it('u$min()', () => { - type.u$min(30, 20).should.eql(20); - type.u$min(10, 20).should.eql(10); - }); -}); diff --git a/media/scripts/types/object.ts b/media/scripts/types/object.ts deleted file mode 100644 index 960b651c..00000000 --- a/media/scripts/types/object.ts +++ /dev/null @@ -1,11 +0,0 @@ -import chai from 'chai'; -const should = chai.should(); // eslint-disable-line -import SchemaTypeObject from '../../../dist/types/object'; - -describe('SchemaTypeObject', () => { - const type = new SchemaTypeObject('test'); - - it('cast() - default', () => { - (type.cast() as object).should.eql({}); - }); -}); diff --git a/media/scripts/types/string.ts b/media/scripts/types/string.ts deleted file mode 100644 index ebbda208..00000000 --- a/media/scripts/types/string.ts +++ /dev/null @@ -1,83 +0,0 @@ -import chai from 'chai'; -const should = chai.should(); // eslint-disable-line -import ValidationError from '../../../dist/error/validation'; -import SchemaTypeString from '../../../dist/types/string'; - -describe('SchemaTypeString', () => { - const type = new SchemaTypeString('test'); - - it('cast()', () => { - type.cast('foo').should.eql('foo'); - type.cast(42).should.eql('42'); - type.cast(true).should.eql('true'); - type.cast([1, 2, 3]).should.eql('1,2,3'); - type.cast({}).should.eql('[object Object]'); - type.cast({ - toString: function() { - return 'baz'; - } - }).should.eql('baz'); - }); - - it('cast() - default', () => { - const type = new SchemaTypeString('test', {default: 'foo'}); - (type.cast() as string).should.eql('foo'); - }); - - function shouldThrowError(value) { - (() => type.validate(value)).should.to.throw(ValidationError, `\`${value}\` is not a string!`); - } - - it('validate()', () => { - type.validate('foo').should.eql('foo'); - type.validate('').should.eql(''); - shouldThrowError(1); - shouldThrowError(0); - shouldThrowError(true); - shouldThrowError(false); - shouldThrowError([]); - shouldThrowError({}); - }); - - it('validate() - required', () => { - const type = new SchemaTypeString('test', {required: true}); - - type.validate.bind(type).should.to.throw(ValidationError, '`test` is required!'); - }); - - it('match()', () => { - type.match('foo', 'foo').should.be.true; - type.match('foo', 'bar').should.be.false; - type.match(undefined, '').should.be.false; - type.match(undefined, undefined).should.be.true; - }); - - it('match() - RegExp', () => { - type.match('foo', /^f/).should.be.true; - type.match('bar', /^f/).should.be.false; - type.match(undefined, /^f/).should.be.false; - }); - - it('q$in()', () => { - type.q$in('foo', ['foo', 'bar', 'baz']).should.be.true; - type.q$in('wat', ['foo', 'bar', 'baz']).should.be.false; - type.q$in(undefined, ['foo', 'bar', 'baz']).should.be.false; - type.q$in('foo', [/^f/, /^g/]).should.be.true; - type.q$in('bar', [/^f/, /^g/]).should.be.false; - }); - - it('q$nin()', () => { - type.q$nin('foo', ['foo', 'bar', 'baz']).should.be.false; - type.q$nin('wat', ['foo', 'bar', 'baz']).should.be.true; - type.q$nin(undefined, ['foo', 'bar', 'baz']).should.be.true; - type.q$nin('foo', [/^f/, /^g/]).should.be.false; - type.q$nin('bar', [/^f/, /^g/]).should.be.true; - }); - - it('q$length()', () => { - type.q$length('foo', 3).should.be.true; - type.q$length('foo', 5).should.be.false; - type.q$length(undefined, 3).should.be.false; - type.q$length(undefined, 0).should.be.true; - }); -}); diff --git a/media/scripts/types/virtual.ts b/media/scripts/types/virtual.ts deleted file mode 100644 index 117aad25..00000000 --- a/media/scripts/types/virtual.ts +++ /dev/null @@ -1,57 +0,0 @@ -import chai from 'chai'; -const should = chai.should(); // eslint-disable-line -import SchemaTypeVirtual from '../../../dist/types/virtual'; - -describe('SchemaTypeVirtual', () => { - const type = new SchemaTypeVirtual('test'); - - it('get()', () => { - const getter = () => 'foo'; - - type.get(getter); - (type.getter as () => any).should.eql(getter); - }); - - it('get() - type check', () => { - // @ts-expect-error - (() => type.get(123)).should.to.throw(TypeError, 'Getter must be a function!'); - }); - - it('set()', () => { - const setter = function() { - this.foo = 'foo'; - }; - - type.set(setter); - (type.setter as () => any).should.eql(setter); - }); - - it('set() - type check', () => { - // @ts-expect-error - (() => type.set(123)).should.to.throw(TypeError, 'Setter must be a function!'); - }); - - it('cast()', () => { - const obj = {name: 'foo'}; - - type.get(function() { - return this.name.toUpperCase(); - }); - - type.cast(undefined, obj); - // @ts-ignore - obj.test.should.eql('FOO'); - }); - - it('validate()', () => { - const obj = {}; - - type.set(function(value) { - this.name = value.toLowerCase(); - }); - - type.validate('FOO', obj); - // @ts-ignore - obj.name.should.eql('foo'); - }); -}); diff --git a/media/scripts/util.ts b/media/scripts/util.ts deleted file mode 100644 index b56f4b80..00000000 --- a/media/scripts/util.ts +++ /dev/null @@ -1,180 +0,0 @@ -import chai from 'chai'; -const should = chai.should(); // eslint-disable-line -import * as util from '../../dist/util'; - -describe('util', () => { - it('shuffle()', () => { - const src = Array(100).fill(0).map((_, i) => i); - const result = util.shuffle(src); - - result.should.not.eql(src); - result.should.to.have.members(src); - result.should.to.have.length(src.length); - - src.should.eql(Array(100).fill(0).map((_, i) => i)); - }); - - it('shuffle() - array must be an array', () => { - (() => util.shuffle({})).should.to.throw('array must be an Array!'); - }); - - it('getProp()', () => { - const obj = { - a: { - b: 1 - }, - c: 2, - d: { - e: { - f: 'foo' - } - } - }; - - util.getProp(obj, 'a.b').should.eql(obj.a.b); - util.getProp(obj, 'c').should.eql(obj.c); - util.getProp(obj, 'd.e.f').should.eql(obj.d.e.f); - }); - - it('getProp() - obj must be an object', () => { - (() => util.getProp('', null)).should.to.throw('obj must be an object!'); - }); - - it('getProp() - key is required', () => { - (() => util.getProp({}, null)).should.to.throw('key is required!'); - }); - - it('setProp()', () => { - const obj = { - a: { - b: 1 - }, - c: 2, - d: { - e: { - f: 'foo' - } - } - }; - - util.setProp(obj, 'a.b', 10); - obj.a.b.should.eql(10); - - util.setProp(obj, 'c', 20); - obj.c.should.eql(20); - - util.setProp(obj, 'd.e.f', 'haha'); - obj.d.e.f.should.eql('haha'); - }); - - it('setProp() - obj must be an object', () => { - (() => util.setProp('', null, null)).should.to.throw('obj must be an object!'); - }); - - it('setProp() - key is required', () => { - (() => util.setProp({}, null, null)).should.to.throw('key is required!'); - }); - - it('delProp()', () => { - const obj = { - a: { - b: 1 - }, - c: 2, - d: { - e: { - f: 'foo' - } - } - }; - - util.delProp(obj, 'a.b'); - should.not.exist(obj.a.b); - - util.delProp(obj, 'c'); - should.not.exist(obj.c); - - util.delProp(obj, 'd.e.f'); - should.not.exist(obj.d.e.f); - - util.delProp(obj, 'd.f.g'); - should.exist(obj.d.e); - }); - - it('delProp() - obj must be an object', () => { - (() => util.delProp('', null)).should.to.throw('obj must be an object!'); - }); - - it('delProp() - key is required', () => { - (() => util.delProp({}, null)).should.to.throw('key is required!'); - }); - - it('setGetter()', () => { - const obj = { - a: { - b: 1 - }, - c: 2, - d: { - e: { - f: 'foo' - } - } - }; - - util.setGetter(obj, 'a.b', () => 100); - - obj.a.b.should.eql(100); - - util.setGetter(obj, 'c', () => 200); - - obj.c.should.eql(200); - - util.setGetter(obj, 'd.e.f', () => 'haha'); - - obj.d.e.f.should.eql('haha'); - - util.setGetter(obj, 'a.c.h', () => 'ach'); - - // @ts-ignore - obj.a.c.h.should.eql('ach'); - }); - - it('setGetter() - obj must be an object', () => { - (() => util.setGetter('', null, null)).should.to.throw('obj must be an object!'); - }); - - it('setGetter() - key is required', () => { - (() => util.setGetter({}, null, null)).should.to.throw('key is required!'); - }); - - it('setGetter() - fn must be a function', () => { - (() => util.setGetter({}, 'test', {})).should.to.throw('fn must be a function!'); - }); - - it('arr2obj()', () => { - util.arr2obj(['a', 'b'], 1).should.eql({a: 1, b: 1}); - }); - - it('arr2obj() - arr must be an array', () => { - (() => util.arr2obj({}, null)).should.to.throw('arr must be an array!'); - }); - - it('reverse()', () => { - const arr = [1, '2', 'w']; - - util.reverse(arr).should.eql(['w', '2', 1]); - }); - - it('reverse() - arr must be an array', () => { - (() => util.reverse({})).should.to.throw('arr must be an array!'); - }); - - it('parseArgs()', () => { - util.parseArgs('name').should.eql({name: 1}); - util.parseArgs('name', -1).should.eql({name: -1}); - util.parseArgs('name -date').should.eql({name: 1, date: -1}); - util.parseArgs('name -date +priority').should.eql({name: 1, date: -1, priority: 1}); - util.parseArgs({name: 1}).should.eql({name: 1}); - }); -}); diff --git a/modules/database.html b/modules/database.html index 8883073b..666d3249 100644 --- a/modules/database.html +++ b/modules/database.html @@ -1,2 +1,2 @@ -database | hexojs/warehouse

        Index

        Classes

        \ No newline at end of file +database | hexojs/warehouse

        Index

        Classes

        diff --git a/modules/document.html b/modules/document.html index 4d626c45..a9f5223e 100644 --- a/modules/document.html +++ b/modules/document.html @@ -1,2 +1,2 @@ -document | hexojs/warehouse

        Index

        Classes

        \ No newline at end of file +document | hexojs/warehouse

        Index

        Classes

        diff --git a/modules/error.html b/modules/error.html index 85a62e0a..fd577b57 100644 --- a/modules/error.html +++ b/modules/error.html @@ -1,2 +1,2 @@ -error | hexojs/warehouse

        Index

        Classes

        \ No newline at end of file +error | hexojs/warehouse

        Index

        Classes

        diff --git a/modules/error_population.html b/modules/error_population.html index d5e1bafa..321d04f1 100644 --- a/modules/error_population.html +++ b/modules/error_population.html @@ -1,2 +1,2 @@ -error/population | hexojs/warehouse

        Module error/population

        Index

        Classes

        \ No newline at end of file +error/population | hexojs/warehouse

        Module error/population

        Index

        Classes

        diff --git a/modules/error_validation.html b/modules/error_validation.html index 2588a200..25e1715d 100644 --- a/modules/error_validation.html +++ b/modules/error_validation.html @@ -1,2 +1,2 @@ -error/validation | hexojs/warehouse

        Module error/validation

        Index

        Classes

        \ No newline at end of file +error/validation | hexojs/warehouse

        Module error/validation

        Index

        Classes

        diff --git a/modules/lib_jsonstream.html b/modules/lib_jsonstream.html index a6f91ae4..7d72c7fb 100644 --- a/modules/lib_jsonstream.html +++ b/modules/lib_jsonstream.html @@ -1,2 +1,2 @@ -lib/jsonstream | hexojs/warehouse

        Module lib/jsonstream

        Index

        Functions

        \ No newline at end of file +lib/jsonstream | hexojs/warehouse

        Module lib/jsonstream

        Index

        Functions

        diff --git a/modules/model.html b/modules/model.html index 1c7a793a..cb3cf81b 100644 --- a/modules/model.html +++ b/modules/model.html @@ -1,2 +1,2 @@ -model | hexojs/warehouse

        Index

        Classes

        \ No newline at end of file +model | hexojs/warehouse

        Index

        Classes

        diff --git a/modules/mutex.html b/modules/mutex.html index 2e051856..081c72c5 100644 --- a/modules/mutex.html +++ b/modules/mutex.html @@ -1,2 +1,2 @@ -mutex | hexojs/warehouse

        Index

        Classes

        \ No newline at end of file +mutex | hexojs/warehouse

        Index

        Classes

        diff --git a/modules/query.html b/modules/query.html index 3868c728..644ce8e9 100644 --- a/modules/query.html +++ b/modules/query.html @@ -1,2 +1,2 @@ -query | hexojs/warehouse

        Index

        Classes

        \ No newline at end of file +query | hexojs/warehouse

        Index

        Classes

        diff --git a/modules/schema.html b/modules/schema.html index cad8a0bd..95a8d273 100644 --- a/modules/schema.html +++ b/modules/schema.html @@ -1,2 +1,2 @@ -schema | hexojs/warehouse

        Index

        Classes

        \ No newline at end of file +schema | hexojs/warehouse

        Index

        Classes

        diff --git a/modules/schematype.html b/modules/schematype.html index 33966d25..a90a51e7 100644 --- a/modules/schematype.html +++ b/modules/schematype.html @@ -1,2 +1,2 @@ -schematype | hexojs/warehouse

        Index

        Classes

        \ No newline at end of file +schematype | hexojs/warehouse

        Index

        Classes

        diff --git a/modules/types-1.html b/modules/types-1.html index 827d230d..6c9fcbd4 100644 --- a/modules/types-1.html +++ b/modules/types-1.html @@ -1,4 +1,4 @@ -types | hexojs/warehouse

        Index

        Interfaces

        AddSchemaTypeLoopOptions +types | hexojs/warehouse
        \ No newline at end of file +
        diff --git a/modules/types.html b/modules/types.html index b25023cb..f2bdaead 100644 --- a/modules/types.html +++ b/modules/types.html @@ -1,4 +1,4 @@ -types | hexojs/warehouse

        References

        Array +types | hexojs/warehouse

        References

        References

        Renames and re-exports default
        Renames and re-exports default
        Renames and re-exports default
        Renames and re-exports default
        Renames and re-exports default
        Renames and re-exports default
        Renames and re-exports default
        Renames and re-exports default
        Renames and re-exports default
        Renames and re-exports default
        Renames and re-exports default
        Renames and re-exports default
        \ No newline at end of file +

        References

        Renames and re-exports default
        Renames and re-exports default
        Renames and re-exports default
        Renames and re-exports default
        Renames and re-exports default
        Renames and re-exports default
        Renames and re-exports default
        Renames and re-exports default
        Renames and re-exports default
        Renames and re-exports default
        Renames and re-exports default
        Renames and re-exports default
        diff --git a/modules/types_array.html b/modules/types_array.html index 3d567762..fc86990c 100644 --- a/modules/types_array.html +++ b/modules/types_array.html @@ -1,2 +1,2 @@ -types/array | hexojs/warehouse

        Module types/array

        Index

        Classes

        \ No newline at end of file +types/array | hexojs/warehouse

        Module types/array

        Index

        Classes

        diff --git a/modules/types_boolean.html b/modules/types_boolean.html index 8e64d72d..f538afd5 100644 --- a/modules/types_boolean.html +++ b/modules/types_boolean.html @@ -1,2 +1,2 @@ -types/boolean | hexojs/warehouse

        Module types/boolean

        Index

        Classes

        \ No newline at end of file +types/boolean | hexojs/warehouse

        Module types/boolean

        Index

        Classes

        diff --git a/modules/types_buffer.html b/modules/types_buffer.html index fcd232d4..f2d2071b 100644 --- a/modules/types_buffer.html +++ b/modules/types_buffer.html @@ -1,2 +1,2 @@ -types/buffer | hexojs/warehouse

        Module types/buffer

        Index

        Classes

        \ No newline at end of file +types/buffer | hexojs/warehouse

        Module types/buffer

        Index

        Classes

        diff --git a/modules/types_cuid.html b/modules/types_cuid.html index b0aabb08..a76521f7 100644 --- a/modules/types_cuid.html +++ b/modules/types_cuid.html @@ -1,2 +1,2 @@ -types/cuid | hexojs/warehouse

        Index

        Classes

        \ No newline at end of file +types/cuid | hexojs/warehouse

        Index

        Classes

        diff --git a/modules/types_date.html b/modules/types_date.html index 51710cc3..a108258c 100644 --- a/modules/types_date.html +++ b/modules/types_date.html @@ -1,2 +1,2 @@ -types/date | hexojs/warehouse

        Index

        Classes

        \ No newline at end of file +types/date | hexojs/warehouse

        Index

        Classes

        diff --git a/modules/types_enum.html b/modules/types_enum.html index a4adfb0f..dbce64e8 100644 --- a/modules/types_enum.html +++ b/modules/types_enum.html @@ -1,2 +1,2 @@ -types/enum | hexojs/warehouse

        Index

        Classes

        \ No newline at end of file +types/enum | hexojs/warehouse

        Index

        Classes

        diff --git a/modules/types_integer.html b/modules/types_integer.html index d05c1d94..2619f9c8 100644 --- a/modules/types_integer.html +++ b/modules/types_integer.html @@ -1,2 +1,2 @@ -types/integer | hexojs/warehouse

        Module types/integer

        Index

        Classes

        \ No newline at end of file +types/integer | hexojs/warehouse

        Module types/integer

        Index

        Classes

        diff --git a/modules/types_number.html b/modules/types_number.html index 04a59925..a74b0d85 100644 --- a/modules/types_number.html +++ b/modules/types_number.html @@ -1,2 +1,2 @@ -types/number | hexojs/warehouse

        Module types/number

        Index

        Classes

        \ No newline at end of file +types/number | hexojs/warehouse

        Module types/number

        Index

        Classes

        diff --git a/modules/types_object.html b/modules/types_object.html index 055fde33..9589b8fa 100644 --- a/modules/types_object.html +++ b/modules/types_object.html @@ -1,2 +1,2 @@ -types/object | hexojs/warehouse

        Module types/object

        Index

        Classes

        \ No newline at end of file +types/object | hexojs/warehouse

        Module types/object

        Index

        Classes

        diff --git a/modules/types_string.html b/modules/types_string.html index 34bf06fd..c5fddc6e 100644 --- a/modules/types_string.html +++ b/modules/types_string.html @@ -1,2 +1,2 @@ -types/string | hexojs/warehouse

        Module types/string

        Index

        Classes

        \ No newline at end of file +types/string | hexojs/warehouse

        Module types/string

        Index

        Classes

        diff --git a/modules/types_virtual.html b/modules/types_virtual.html index 78445744..99a6c08a 100644 --- a/modules/types_virtual.html +++ b/modules/types_virtual.html @@ -1,2 +1,2 @@ -types/virtual | hexojs/warehouse

        Module types/virtual

        Index

        Classes

        \ No newline at end of file +types/virtual | hexojs/warehouse

        Module types/virtual

        Index

        Classes

        diff --git a/modules/util.html b/modules/util.html index bc770d11..351ffc42 100644 --- a/modules/util.html +++ b/modules/util.html @@ -1,4 +1,4 @@ -util | hexojs/warehouse

        Index

        Functions

        arr2obj +util | hexojs/warehouse

        Index

        Functions

        \ No newline at end of file +
        diff --git a/types/types-1.AddSchemaTypeMixedOptions.html b/types/types-1.AddSchemaTypeMixedOptions.html index 33da804e..23784655 100644 --- a/types/types-1.AddSchemaTypeMixedOptions.html +++ b/types/types-1.AddSchemaTypeMixedOptions.html @@ -1 +1 @@ -AddSchemaTypeMixedOptions | hexojs/warehouse

        Type Alias AddSchemaTypeMixedOptions

        \ No newline at end of file +AddSchemaTypeMixedOptions | hexojs/warehouse

        Type Alias AddSchemaTypeMixedOptions

        diff --git a/types/types-1.AddSchemaTypeOptions.html b/types/types-1.AddSchemaTypeOptions.html index 8a5b66f0..6a20388d 100644 --- a/types/types-1.AddSchemaTypeOptions.html +++ b/types/types-1.AddSchemaTypeOptions.html @@ -1 +1 @@ -AddSchemaTypeOptions | hexojs/warehouse
        \ No newline at end of file +AddSchemaTypeOptions | hexojs/warehouse
        diff --git a/types/types-1.AddSchemaTypeSimpleOptions.html b/types/types-1.AddSchemaTypeSimpleOptions.html index 08ff0663..5deb352e 100644 --- a/types/types-1.AddSchemaTypeSimpleOptions.html +++ b/types/types-1.AddSchemaTypeSimpleOptions.html @@ -1 +1 @@ -AddSchemaTypeSimpleOptions | hexojs/warehouse

        Type Alias AddSchemaTypeSimpleOptions

        AddSchemaTypeSimpleOptions: SchemaTypeOptions | {
            type: SchemaTypeOptions;
            [key: string]: any;
        }
        \ No newline at end of file +AddSchemaTypeSimpleOptions | hexojs/warehouse

        Type Alias AddSchemaTypeSimpleOptions

        AddSchemaTypeSimpleOptions: SchemaTypeOptions | {
            type: SchemaTypeOptions;
            [key: string]: any;
        }
        diff --git a/types/types-1.NodeJSLikeCallback.html b/types/types-1.NodeJSLikeCallback.html index c61ecb71..aece12ce 100644 --- a/types/types-1.NodeJSLikeCallback.html +++ b/types/types-1.NodeJSLikeCallback.html @@ -1 +1 @@ -NodeJSLikeCallback | hexojs/warehouse

        Type Alias NodeJSLikeCallback<R, E>

        NodeJSLikeCallback<R, E>: ((err: E, result?: R) => void)

        Type Parameters

        • R
        • E = any
        \ No newline at end of file +NodeJSLikeCallback | hexojs/warehouse

        Type Alias NodeJSLikeCallback<R, E>

        NodeJSLikeCallback<R, E>: ((err: E, result?: R) => void)

        Type Parameters

        • R
        • E = any
        diff --git a/types/types-1.PopulateResult.html b/types/types-1.PopulateResult.html index 3c2a84d5..1b4b2b41 100644 --- a/types/types-1.PopulateResult.html +++ b/types/types-1.PopulateResult.html @@ -1 +1 @@ -PopulateResult | hexojs/warehouse

        Type Alias PopulateResult

        PopulateResult: {
            model: any;
            path: string;
        }
        \ No newline at end of file +PopulateResult | hexojs/warehouse

        Type Alias PopulateResult

        PopulateResult: {
            model: any;
            path: string;
        }
        diff --git a/types/types-1.SchemaTypeOptions.html b/types/types-1.SchemaTypeOptions.html index f2bfd718..63374ed7 100644 --- a/types/types-1.SchemaTypeOptions.html +++ b/types/types-1.SchemaTypeOptions.html @@ -1 +1 @@ -SchemaTypeOptions | hexojs/warehouse

        Type Alias SchemaTypeOptions

        SchemaTypeOptions: typeof default | default<unknown> | ((...args: any[]) => any)
        \ No newline at end of file +SchemaTypeOptions | hexojs/warehouse

        Type Alias SchemaTypeOptions

        SchemaTypeOptions: typeof default | default<unknown> | ((...args: any[]) => any)