Releases: mswjs/data
Releases · mswjs/data
v0.8.1
v0.8.0
v0.7.2
v0.7.1
Features
- Adds
in
andnotIn
number comparators (#150).
import { factory, primaryKey } from '@mswjs/data'
const data = factory({
user: {
id: primaryKey(String),
age: Number
}
})
data.user.findMany({
where: {
age: { in: [18, 24, 32] }
}
})
Note that
in
/notIn
act asArray.prototype.includes
and do not represent a permitted range of numbers. Usebetween
/notBetween
to query by range.
Bug fixes
v0.7.0
v0.6.0
Breaking changes
- Relational properties can no longer be updated using compatible plain objects (#130). Always use an entity reference when updating a relational property.
const db = factory({
user: {
id: primaryKey(String),
country: oneOf('country'),
},
country: {
code: primaryKey(String),
},
})
db.user.update({
where: {
id: { equals: 'user-1' }
},
data: {
// Always provide a reference
// to an existing entity.
country: db.country.create({
code: 'us'
})
}
})
Features
- Model definition now supports nested objects and arrays (#113).
const db = factory({
user: {
id: primaryKey(String),
address: {
billing: {
street: String,
phoneNumbers: [],
country: oneOf('country'),
},
},
},
})
- Supports updating relational properties (#126).
Bug fixes
- Fixes an issue that prevented an update of a property if it wasn't specified when the entity was created (#130).
- Fixes an issue that broke the querying by an entity's property if that property has no value (#130).
db.user.create({ id: 'abc-123' })
// The following query would throw.
db.user.findFirst({ where: { anotherProperty: { equals: 'value' } } })
- Fixes an issue that would throw an exception when validating a unique relational value if that value is currently assigned to the entity that's being operated on (must exclude the current entity from the validation query) (#130).
v0.5.1
v0.5.0
v0.4.1
v0.4.0
Features
- Adds a
.toSchema()
method on a model factory to generate a GraphQL schema (#96).
import { factory, primaryKey } from '@mswjs/data'
const db = factory({
user: {
id: primaryKey(() => 'abc-123')
}
})
const graphqlSchema = db.toSchema()
-
Numbers can be used as primary keys.
-
Supports filtering entities by their properties in request query parameters (#69):
import { setupServer } from 'msw/node'
import { factory, primaryKey } from '@mswjs/data'
const db = factory({
user: {
id: primaryKey(() => 'abc-123')
}
})
const server = db.user.toHandlers('rest')
fetch('/users?id=abc-123')
Bug fixes
- Fixes an issue when dropping a database and referencing a
db.*.getAll()
on a model that had a relational property raised an exception (#101).