Migrating to Ghost: How to generate primary ID for posts and other entities?

Hi,

I am migrating to Ghost from database with integer auto-increment IDs (1,2,3,…). I see ghost uses IDs like 625f1cb98b49f500010f1903. What type of ID is that and how can I generate it?

Thanks

With NodeJS and UUID library installed you can do something like this :

import { v4 } from 'uuid';
const ghostId = v4().replace(/-/g, '').slice(0, 24);

It’s a “BSON ObjectID”. Ghost uses bson-objectid to generate them.