forked from cadence/out-of-your-element
orm: fix pluck, add basic tests
This commit is contained in:
parent
a8f387c161
commit
d81aa51787
3 changed files with 36 additions and 1 deletions
|
@ -32,6 +32,7 @@ class From {
|
|||
this.sql = ""
|
||||
this.cols = []
|
||||
this.using = []
|
||||
this.isPluck = false
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -69,6 +70,7 @@ class From {
|
|||
const r = this
|
||||
r.constructor = Pluck
|
||||
r.cols = [col]
|
||||
r.isPluck = true
|
||||
return r
|
||||
}
|
||||
|
||||
|
@ -89,7 +91,8 @@ class From {
|
|||
}
|
||||
sql += this.sql
|
||||
/** @type {U.Prepared<Pick<U.Merge<U.Models[Table]>, Col>>} */
|
||||
const prepared = db.prepare(sql)
|
||||
let prepared = db.prepare(sql)
|
||||
if (this.isPluck) prepared = prepared.pluck()
|
||||
return prepared
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue