From 6962ba115e2e3ecd659b51397ee16b3bf9bd20b6 Mon Sep 17 00:00:00 2001 From: Laurent Cozic Date: Tue, 19 Sep 2023 14:52:59 +0100 Subject: [PATCH] Server: Add function to get db default value --- packages/server/schema.sqlite | Bin 339968 -> 339968 bytes .../server/src/services/database/types.ts | 8 ++++++++ 2 files changed, 8 insertions(+) diff --git a/packages/server/schema.sqlite b/packages/server/schema.sqlite index e1754d5545fc4e8aa9db3c50e3de1f91487afc51..5543030e66ac4c4478c403f3834db5d0eaab4a40 100644 GIT binary patch delta 1130 zcmZp8Aky$aWW!2H=50s+PhKOb4yLb38UX2klR2d{fb`$VCQ@cV`p@KCDPti0Yw}_# zO(6Ys@_8`*W%6$+Wg!3aWJPHsApLf7n6w(0u9sE<($6L@kp`Ljbn-c{_>;-sr9t{1 zPga&u1=HR#+CcizC=;U z$b#fgPJS*6vggEP9yyS`CnlT9f!uw3a)KO4{Mh7HIgmX^Ca;wP`RnlH2XY|$4^8Hg z2dP^**&Ix-n4BaJQnze!mpn+{lF94kLFyJyz76It+N98@Umu?6lj4?_=4E0SSmc;v z>Sdl(R9Kdkn39{B=a7@1oS2i5UtFSMl&E58pi*L3<(K3Zky&98W?ozXRF@gzV(#xB z6lEOd?pP4)<64p#9Of34Z>;ZEB*|>aiQQ~21_lO3{=Bglu0U2C@;^@5NPXFX%!e+G6|!(Dzc?C#$*Vb*-7;-tdN z(vpe*lL*U<{B+CIDtEtZ_d@I%u&bT^a0iP753&n3HN4^%!>$;Q)V2UdoZ7Y}FdoVm zD+utkbc!<0u8ayZ%{M7=OgAny%nF%)<2<80C*1pB8?dX~_JHw~JPuP9O>o$>fLmcZ zcLLM>cpL$??En)E6B_;)We{M1#OQY34@@|t6zGdZ3k0?WFn{+4hR8c`q`X@+Apt13 c=>oUHV(tkBKp(QGMKhb58*ew+&2pv$06F2ba{vGU delta 1130 zcmZp8Aky$aWW!2H=9<45lh;V91L^e1*CY*qblPN2DGeZ*vaR?boAukQp!Mn^khY8BOo0-IZRp&OxH^*0cnrPOQb>Ox=lU@7I&HaT^gj{ zd9t#MDwy_`(FW2^lPhH`fV9KpEixec>?XgJ(E-vHlVxO0fVBDKU|Ep)Mw2^ab%C_( z zTY0i&YH6yzccx34e@3yMo@=CMwxfBJr-hFsvn3~Xv$+@;7#R8AG5`?+!)D%qyZp>R zg`3~T|AjL07xL50Stgm~CCSO=h3<|ZA2N2Wt@%>{AtBCs#=!p!?5u{n{9@SMziGm( z`A#KCiG^iR{=VL62ANe6u6gC|kF&?RH0gO1c zZA)N0lrLsz8f96WUG8jIU=f+@Z;)46RN!pxHvPtVMtM%S_rW$`SGny0<12X_rYxG^ zuxSCe!glTiru*?Y0&Lp>CK@I*{4vTPzyOKS?YtkDa7HQ67mF4MYztui?$25CHv|+Z ke?t~cNB|0My1=cln0tZ&(1$E)(aZ*>X4_46vz#db0LA5>A^-pY diff --git a/packages/server/src/services/database/types.ts b/packages/server/src/services/database/types.ts index c6ea08965..d4d3bc438 100644 --- a/packages/server/src/services/database/types.ts +++ b/packages/server/src/services/database/types.ts @@ -75,6 +75,14 @@ export function changeTypeToString(t: ChangeType): string { throw new Error(`Unkown type: ${t}`); } +export const getDefaultValue = (tableName: string, colName: string): string|number|null => { + const table = databaseSchema[tableName]; + if (!table) throw new Error(`Invalid table name: ${tableName}`); + const col = table[colName]; + if (!col) throw new Error(`Invalid column name: ${tableName}.${colName}`); + return col.defaultValue; +}; + export enum ShareType { Note = 1, // When a note is shared via a public link Folder = 3, // When a complete folder is shared with another Joplin Server user