Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add docs for the float field type #4961

Merged
merged 1 commit into from
Feb 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Add docs for the float field type
  • Loading branch information
timleslie committed Feb 28, 2021
commit e9596735ea4d8c6099122ff5acd25641964d6564
5 changes: 5 additions & 0 deletions .changeset/shiny-glasses-hunt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@keystone-next/website': patch
---

Added docs for the `float` field type.
38 changes: 38 additions & 0 deletions docs-next/pages/apis/fields.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
// Scalar types
checkbox,
integer,
float,
password,
select,
text,
Expand Down Expand Up @@ -178,6 +179,43 @@ export default config({
});
```

### float

A `float` field represents a floating point value.

Options:

- `defaultValue` (default: `undefined`): Can be either a float value or an async function which takes an argument `({ context, originalItem })` and returns a float value.
This value will be used for the field when creating items if no explicit value is set.
`context` is a [`KeystoneContext`](./context) object.
`originalItem` is an object containing the data passed in to the `create` mutation.
- `isRequired` (default: `false`): If `true` then this field can never be set to `null`.
- `isIndexed` (`knex` and `mongoose` adapters only. Default: `false`): If `true` a database level index will be applied to this field, which can make searching faster.
- `isUnique` (default: `false`): If `true` then all values of this field must be unique.

```typescript
import { config, createSchema, list } from '@keystone-next/keystone/schema';
import { float } from '@keystone-next/fields';

export default config({
lists: createSchema({
ListName: list({
fields: {
fieldName: float({
defaultValue: 3.14159,
isRequired: true,
isIndexed: true,
isUnique: true,
}),
/* ... */
},
}),
/* ... */
}),
/* ... */
});
```

### password

A `password` field represents an encrypted password value.
Expand Down