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 the way you think, not the way your CMS thinks

Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.

Was this answer helpful?