Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Are Nuxt Content V3 Document IDs Reliable for External References? #3022

Open
khawarizmus opened this issue Jan 23, 2025 · 3 comments
Open
Labels
question Further information is requested v3

Comments

@khawarizmus
Copy link

Background

Nuxt Content V3 automatically assigns unique IDs to documents in its underlying database system. I'm considering using these IDs as reference pointers in my backend system.

Questions

How reliable and consistent are these automatically generated document IDs?
What happens to document IDs in specific scenarios:

When a document is deleted, is its ID permanently retired?
Can newly added documents reuse IDs from previously deleted documents?

Use Case Context

I need to understand the ID behavior to determine if they're suitable for use as stable references in external systems, particularly our backend services.

@farnabaz
Copy link
Member

They are reliable yes. IDs consist of Collection name and file path.
I assume you don't have two files with the same path in a collection and you can use the id column to retrieve and manage content.

@farnabaz farnabaz added question Further information is requested v3 labels Jan 23, 2025
@khawarizmus
Copy link
Author

So if i delete a file from a path and then recreate it. It will have the same ID? in the sense it's deterministic?

Also looking at this comment #1797 (comment) I am a bit confused as do we commit the db or gitignore it. and what are the implications of both in this context (making sure that my Ids are consistent when used with an external system like a custom backend).

@farnabaz
Copy link
Member

Nuxt Content is still a file-based content management module and the ground truth is the content files. However in order to improve performance and type safety the module leverages the database in production.

I suggest not modifying the contents in production, because the module is not designed for this purpose and you may find unexpected behaviors In edge cases. (This feature is not planned for v3 but might be supported in the future)

But as for IDs, you can trust ids to retrieve and fetch the contents from an external system.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested v3
Projects
None yet
Development

No branches or pull requests

2 participants