I was thinking of using cuid (https://www.npmjs.com/package/cuid) to replace mongoose's naturally generated objectids, so that _id
in my model would get a cuid rather than a generated one.
Questions:
- How do you achieve this
- Are there any side effects
- How would this affect population??
Is 1 as simple as:
import mongoose from 'mongoose';
import cuid from 'cuid';
const Schema = mongoose.Schema;
export const departmentSchema = new Schema({
_id: { type: 'String', default: cuid(), required: true },
name: { type: 'String', required: true },
sector: { type: 'String', required: true },
});
??
Thanks