Unlock seamless workflows and faster delivery with our latest releases ā€“ get the details

Dataset Import - How to Format the Ndjson File for References

4 replies
Last updated: Aug 16, 2022
hi all! working on a dataset import right now and trying to figure out how to format my
ndjson
file to account for references.
this is part of the schema iā€™m importing into, specifically wondering how I should format for the
pressLinks
field

...
        {
            name: 'pressLinks',
            title: 'Selected Press',
            type: 'array',
            of: [{ type: 'pressLinks' }],
            group: 'press',
        },
...
Aug 16, 2022, 6:27 PM
Hey
user E
! Are presslinks objects or references?
Aug 16, 2022, 6:30 PM
they are objects, here is the schema

export default {
    name: 'pressLinks',
    title: 'Press Links',
    type: 'object',
    fields: [
        {
            name: 'title',
            title: 'Press Outlet Name',
            type: 'string',
        }, {
            name: 'url',
            title: 'Press Link URL',
            type: 'url',
        }
    ],
}
Aug 16, 2022, 6:30 PM
Got it! I wasn't sure because of this:
trying to figure out how to format my
ndjson
file to account for references.
For presslinks, they would need to be in this format.
{
 //...other fields
  pressLinks: [
    {
       _type: 'pressLink',
       title: <your-title>,
       url: <your-url
    },
    //...other pressLinks
  ]
}
Aug 16, 2022, 6:36 PM
user M
perfect thank you so much! was just missing the
_type
property šŸ™‚
Aug 16, 2022, 6:37 PM

Sanityā€“ build remarkable experiences at scale

Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?