Skip to content

Commit

Permalink
Add docs for the float field type (#4961)
Browse files Browse the repository at this point in the history
  • Loading branch information
timleslie authored Feb 28, 2021
1 parent 880fd5f commit 1f315bb
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
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

1 comment on commit 1f315bb

@vercel
Copy link

@vercel vercel bot commented on 1f315bb Feb 28, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.