Spaces:
Sleeping
Sleeping
Download models/BranchModel.js from Mahmoud7456/MultiUsersSalesSystem: direct link, hf CLI and curl.
- Browser
- Download file 1.54 kB
-
https://huggingface.co/spaces/Mahmoud7456/MultiUsersSalesSystem/resolve/main/models/BranchModel.js
- Command line
-
hf download hf://spaces/Mahmoud7456/MultiUsersSalesSystem/models/BranchModel.js
-
curl -L -o BranchModel.js https://huggingface.co/spaces/Mahmoud7456/MultiUsersSalesSystem/resolve/main/models/BranchModel.js
1.54 kB
| import mongoose from "mongoose"; | |
| const branchSchema = new mongoose.Schema( | |
| { | |
| tenant: { | |
| type: mongoose.Schema.Types.ObjectId, | |
| ref: "Tenant", | |
| required: true, | |
| index: true, | |
| }, | |
| name: { | |
| type: String, | |
| required: true, | |
| trim: true, | |
| }, | |
| code: { | |
| type: String, | |
| trim: true, | |
| // default: null, | |
| // set: v => (v && v.trim() !== "" ? v.trim() : null) | |
| }, | |
| address: { | |
| type: String, | |
| trim: true, | |
| default: "", | |
| }, | |
| managerName: { | |
| type: String, | |
| trim: true, | |
| default: "", | |
| }, | |
| settings: { | |
| taxRate: { | |
| type: Number, | |
| default: null, // null = inherit from tenant settings | |
| min: 0, | |
| max: 1, | |
| }, | |
| }, | |
| isPrimary: { | |
| type: Boolean, | |
| default: false, | |
| }, | |
| status: { | |
| type: String, | |
| enum: ["active", "suspended"], | |
| default: "active", | |
| }, | |
| createdBy: { | |
| type: mongoose.Schema.Types.ObjectId, | |
| ref: "User", | |
| default: null, | |
| }, | |
| }, | |
| { timestamps: true } | |
| ); | |
| branchSchema.index({ tenant: 1, name: 1 }, { unique: true }); | |
| branchSchema.index( | |
| { tenant: 1, code: 1 }, | |
| { | |
| unique: true, | |
| partialFilterExpression: { | |
| code: { $type: "string" } | |
| } | |
| } | |
| ); | |
| export default mongoose.model("Branch", branchSchema); | |