Files
medusa-store/packages/medusa-test-utils/src/id-map.js
Sebastian Rindom 706ca8ac45 Makes ProductVariant operations go through ProductService (#68)
Ensures that we can reliably manage product variants and their relationship to products
2020-05-28 11:44:11 +02:00

24 lines
385 B
JavaScript

import mongoose from "mongoose"
String.prototype.equals = function(that) {
return this === that
}
class IdMap {
ids = {}
getId(key, backend=false) {
if (this.ids[key]) {
return this.ids[key]
}
const mongooseId = `${mongoose.Types.ObjectId()}`
this.ids[key] = mongooseId
return mongooseId
}
}
const instance = new IdMap()
export default instance