Releases: haltcase/trilogy
Releases · haltcase/trilogy
v2.0.0-rc.1
yarn add trilogy@2.0.0-rc.1
v1.4.5
v2.0.0-beta.2
npm i trilogy@2.0.0-beta.2
v1.4.4
v1.4.3
v1.4.2
v1.4.1
v1.4.0
v1.3.0
This release brings a pair of exciting features!
First up is the ability to define getters and setters when creating models.
These are useful for things like formatting after selects and conforming
data before inserts.
const people = await db.model('people', {
name: String,
username: {
type: String,
get (username) {
return `username is: ${username}`
},
set (username) {
// remove anything that isn't alphanumeric or underscore
return username.replace(/[^\w]/gi, '')
}
}
})
await people.create({
name: 'Bo Lingen',
username: 'ci.ty]ci[d/e'
})
// -> { name: 'Bo Lingen', username: 'citycide' }
await people.get('username', { name: 'Bo Lingen' })
// -> 'username is: citycide'
// can use `getRaw()` and `setRaw()` to bypass getters / setters
// other methods may also accept a `raw` property in their options object
await people.getRaw('username', { name: 'Bo Lingen' })
// -> 'citycide'
There's also a new memory-only mode - if the file path is exactly ':memory:',
no file will be created and an in-memory store will be used. This doesn't
persist any data but is useful for speed and performance reasons. For example,
most of trilogy's tests now use in-memory databases to avoid tons of disk usage.
const db = new Trilogy(':memory:')
BUG FIXES
- always return promises in async functions (009f079)
FEATURES
- add support for in-memory database (8587f4b)
- add getters & setters (ab5cd7b)
- add
getRaw()
&setRaw()
(5fe1f80)