content icon indicating copy to clipboard operation
content copied to clipboard

Custom `id` Field

Open cco3 opened this issue 3 months ago • 2 comments

Using @nuxt/content v3, what is the simplest way of querying on a custom id field?

The flat database I'm using is imported from elsewhere and I don't want to massage it first. If it is full of yml files with an id field, how can I specify my collection so that I can query on this field? It seems to be overwritten by @nuxt/content's own id field.

cco3 avatar Oct 17 '25 17:10 cco3

Indeed id is a specific key for Nuxt Content and module overwrite it. There is not solution for overwriting id field at the time. Could you provide a simple reproduction of what you want to achieve? There might be some workarounds for reach your goal

farnabaz avatar Oct 27 '25 14:10 farnabaz

I have a large set of yml files I want to import that have ids in them. Example

I do not want to massage the data or edit it before importing it.

My current solution is to add symbolics_id to my schema and use the content:file:afterParse hook to set the value with ctx.content.symbolics_id = ctx.content.meta.body.id. It took me a while to make this hack; I'd prefer something simpler.

cco3 avatar Oct 27 '25 18:10 cco3