3.0 KiB
title, tags, aliases
| title | tags | aliases | |||||
|---|---|---|---|---|---|---|---|
| ShopSettings |
|
|
ShopSettings
One-to-one storefront configuration for a seller. Holds the shop name, description, avatar, cover image, public visibility flag, review toggles (allowSellerReviews, allowTemplateReviews), and social links. The unique constraint on sellerId enforces the one-shop-per-seller invariant.
[!note] Source
backend/src/models/ShopSettings.ts:22— schema definitionbackend/src/models/ShopSettings.ts:86— model export
Schema
| Field | Type | Required | Default | Validation | Index | Description |
|---|---|---|---|---|---|---|
sellerId |
ObjectId → User | yes | — | — | unique | Owning seller (one shop per seller). |
name |
String | yes | — | trim | — | Shop name. |
description |
String | no | "" |
trim | — | Shop description. |
avatar |
String | no | "" |
— | — | Avatar URL. |
coverImage |
String | no | "" |
— | — | Cover image URL. |
isPublic |
Boolean | no | true |
— | — | Public visibility flag. |
allowSellerReviews |
Boolean | no | true |
— | — | Whether buyers can review the seller. |
allowTemplateReviews |
Boolean | no | true |
— | — | Whether buyers can review templates. |
socialLinks.facebook |
String | no | "" |
— | — | Facebook URL. |
socialLinks.instagram |
String | no | "" |
— | — | Instagram URL. |
socialLinks.linkedin |
String | no | "" |
— | — | LinkedIn URL. |
socialLinks.twitter |
String | no | "" |
— | — | Twitter / X URL. |
createdAt |
Date | auto | — | — | — | Mongoose timestamp. |
updatedAt |
Date | auto | — | — | — | Mongoose timestamp. |
Virtuals
None defined.
Indexes
- Implicit unique index on
sellerId(fromunique: true). No additional indexes are declared (see comment atbackend/src/models/ShopSettings.ts:84).
Pre/Post Hooks
None declared.
Instance Methods
None defined.
Static Methods
None defined.
Relationships
State Transitions
No status field. The isPublic boolean is the only visibility control:
stateDiagram-v2
[*] --> public
public --> private : seller toggles off
private --> public : seller toggles on
Common Queries
// Fetch the seller's shop
ShopSettings.findOne({ sellerId });
// Upsert on first save
ShopSettings.findOneAndUpdate(
{ sellerId },
{ $set: { name, description, ... } },
{ upsert: true, new: true }
);
// Public shop directory
ShopSettings.find({ isPublic: true }).sort({ createdAt: -1 });
[!warning] Creating two shops will fail Inserting a second
ShopSettingsdocument with the samesellerIdwill fail withE11000 duplicate key. Application code should always usefindOneAndUpdatewithupsert: true.
Related: User, Review, RequestTemplate.