@dbnx/mysql
Advanced tools
Comparing version 1.0.17 to 1.0.18
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.update=update;const utilities_1=require("../utilities"),utils_1=require("./utils");function update(e,{joins:t=[],values:i,where:r="",defaultValues:o=[],limit:n,sort:s,fromSubQuery:u,setCalculations:l}){var a;if(!e)throw new Error("⚠️ The `table` parameter is required.");if(!r)throw new Error("⚠️ The `where` parameter is required.");if(!(i||o.length||l||u))throw new Error("⚠️ No update data provided.");let $="";for(const e in i){if(!i.hasOwnProperty(e))continue;const t=i[e];if("object"==typeof t&&(null==t?void 0:t.hasOwnProperty("case"))){$+=`${$?", ":""}${e} = CASE ${null===(a=null==t?void 0:t.case)||void 0===a?void 0:a.map((e=>{const{when:t,then:i}=e;return`WHEN ${t} THEN ${(0,utilities_1.escape)(i)}`})).join(" ")} ELSE ${(0,utilities_1.escape)(null==t?void 0:t.default)} END`}else{const i=null==t;$+=`${$?", ":""}${e} = ${"string"==typeof t?(0,utilities_1.escape)(null==t?void 0:t.trim()):i?"NULL":t}`}}const c=l||{},p=u||{};for(const e in c){if(!c.hasOwnProperty(e))continue;$+=`${$?", ":""}${e} = ${c[e]}`}for(const e in p){if(!p.hasOwnProperty(e))continue;$+=`${$?", ":""}${e} = ${p[e]}`}if(null==o?void 0:o.length)for(const e of o)$+=`${$?", ":""}${e} = DEFAULT`;let d=`UPDATE${(0,utils_1.parseJoins)(t)} ${e} SET ${$}`;return r&&(d+=` WHERE ${r}`),s&&(d+=(0,utils_1.parseSort)(s)),n&&(d+=` LIMIT ${n}`),`${d};`} | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.update=update;const utilities_1=require("../utilities"),utils_1=require("./utils");function update(e,{joins:t=[],values:r,where:i="",defaultValues:o=[],limit:n,sort:s,fromSubQuery:u,setCalculations:l}){var a;if(!e)throw new Error("⚠️ The `table` parameter is required.");if(!i)throw new Error("⚠️ The `where` parameter is required.");if(!(r||o.length||l||u))throw new Error("⚠️ No update data provided.");let $="";for(const e in r){if(!r.hasOwnProperty(e))continue;const t=r[e];if("object"==typeof t&&(null==t?void 0:t.hasOwnProperty("case"))){$+=`${$?", ":""}${e} = CASE ${null===(a=null==t?void 0:t.case)||void 0===a?void 0:a.map((e=>{const{when:t,then:r}=e;return`WHEN ${t} THEN ${(0,utilities_1.escape)(r)}`})).join(" ")} ELSE ${(0,utilities_1.escape)(null==t?void 0:t.default)} END`}else{$+=`${$?", ":""}${e} = ${"number"==typeof t?t:(0,utilities_1.escape)(t).trim()}`}}const p=l||{},c=u||{};for(const e in p){if(!p.hasOwnProperty(e))continue;$+=`${$?", ":""}${e} = ${p[e]}`}for(const e in c){if(!c.hasOwnProperty(e))continue;$+=`${$?", ":""}${e} = ${c[e]}`}if(null==o?void 0:o.length)for(const e of o)$+=`${$?", ":""}${e} = DEFAULT`;let f=`UPDATE${(0,utils_1.parseJoins)(t)} ${e} SET ${$}`;return i&&(f+=` WHERE ${i}`),s&&(f+=(0,utils_1.parseSort)(s)),n&&(f+=` LIMIT ${n}`),`${f};`} |
{ | ||
"name": "@dbnx/mysql", | ||
"version": "1.0.17", | ||
"version": "1.0.18", | ||
"description": "A powerful and enhanced ORM library for MySQL, offering query execution, model creation, and full relational management.", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
//! ********************************** FOR CREATE ********************************* | ||
export type CreateParamsType<columns extends any[]> = { | ||
[P in columns[number]]?: string | "CURRENT_TIMESTAMP" | ||
} | Record<string, string | number | 'CURRENT_TIMESTAMP'> | | ||
[P in columns[number]]?: string | "CURRENT_TIMESTAMP" | undefined | ||
} | Record<string, string | number | 'CURRENT_TIMESTAMP' | undefined> | | ||
{ | ||
@@ -100,3 +100,3 @@ [P in columns[number]]?: string | "CURRENT_TIMESTAMP" | ||
values?: { | ||
[key: string]: string | number | null | { | ||
[key: string]: string | number | null | undefined | { | ||
case: { | ||
@@ -103,0 +103,0 @@ when: string; // The condition in the WHEN clause |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
79737