/* * Common types and interfaces */ import { HasObjectId } from './has-object-id'; // Foreign key field export type Ref = string | T & HasObjectId; export type Nullable = T | null | undefined; export const isPopulated = (ref: Ref): ref is T & HasObjectId => { return !(typeof ref === 'string'); }; export const getIdForRef = (ref: Ref): string => { return isPopulated(ref) ? ref._id : ref; };