Replies: 2 comments 6 replies
-
Hi @osseonews, thanks for your question. It's quite easy to define a unique constraint in Contember. You can use the Here is simplified code how to solve your example: import { SchemaDefinition as def } from '@contember/schema-definition'
@def.Unique('product', 'warehouse')
export class WarehouseInventory {
product = def.manyHasOne(Product, 'inventory')
warehouse = def.manyHasOne(Warehouse, 'inventory')
} |
Beta Was this translation helpful? Give feedback.
-
Thanks for the quick response! Instead of opening up a new discussion, I had one other quick question. Where are the images stored in Contember cloud? When we create an Image field, it automatically creates an upload and we can upload images. But where are these images and how to access them outside of cloud? Is there an Image API of some sort? Can we export the images and host elsewhere? |
Beta Was this translation helpful? Give feedback.
-
How would you create a unique constraint on multiple columns with Contember? For example, we store inventory at multiple warehouses. So we have a join table with WarehouseInventory, with foreign key back to a product_id and warehouse_id. The constraint is that a warehouse_id and product_id are unique, in that you can't have the same product stored twice at the same warehouse. Hope this makes sense.
Beta Was this translation helpful? Give feedback.
All reactions