-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0096c34
commit a10fd20
Showing
1 changed file
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { Client } from '@datocms/cli/lib/cma-client-node'; | ||
|
||
export default async function(client: Client): Promise<void> { | ||
// DatoCMS migration script | ||
|
||
// For more examples, head to our Content Management API docs: | ||
// https://www.datocms.com/docs/content-management-api | ||
|
||
// Create an Article model: | ||
// https://www.datocms.com/docs/content-management-api/resources/item-type/create | ||
|
||
const articleModel = await client.itemTypes.create({ | ||
name: 'Article', | ||
api_key: 'article', | ||
}); | ||
|
||
// Create a Title field (required): | ||
// https://www.datocms.com/docs/content-management-api/resources/field/create | ||
|
||
const titleField = await client.fields.create(articleModel, { | ||
label: 'Title', | ||
api_key: 'title', | ||
field_type: 'string', | ||
validators: { | ||
required: {}, | ||
}, | ||
}); | ||
|
||
// Create an Article record: | ||
// https://www.datocms.com/docs/content-management-api/resources/item/create | ||
|
||
const article = await client.items.create({ | ||
item_type: articleModel, | ||
title: 'My first article!', | ||
}); | ||
} |