How to make a node have a default unique ID?

like this:

attrs: {
   _id: {
        default: uuidv4(),

but it not work

No, default attribute values are just values, they don’t get recomputed for every node. See this thread for similar discussion.

It’s not an elegant solution

Now I use other ways to solve the problem, without using ID.