Merge branch 'main' into typesense

This commit is contained in:
2024-12-31 22:51:16 +03:30
24 changed files with 551 additions and 79 deletions
+21 -5
View File
@@ -1,5 +1,6 @@
const mongoose = require('mongoose')
const ObjectID = mongoose.Schema.Types.ObjectId
const AutoIncrement = require('mongoose-sequence')(mongoose)
const belongingSchema = new mongoose.Schema(
{
@@ -10,14 +11,14 @@ const belongingSchema = new mongoose.Schema(
},
belongingCategory: {
type: ObjectID,
ref: 'Category'
ref: 'Category',
},
projectCode: {
type: String,
required: true,
default: false,
},
relatedProjects : [String],
relatedProjects: [String],
location: {
type: {
type: String,
@@ -29,12 +30,27 @@ const belongingSchema = new mongoose.Schema(
required: true,
},
},
documents: [String]
documents: [String],
numId: {
type: Number,
unique: true,
},
isActive: {
type: Boolean,
default: true,
select: false,
},
},
{ timestamps: true }
{
toJSON: { virtuals: true },
toObject: { virtuals: true },
timestamps: true,
}
)
belongingSchema.index({ location: '2dsphere' }); // Enable geospatial queries
belongingSchema.plugin(AutoIncrement, { inc_field: 'numId' })
belongingSchema.index({ location: '2dsphere' }) // Enable geospatial queries
const Belonging = mongoose.model('Belonging', belongingSchema)
module.exports = Belonging
+1 -1
View File
@@ -15,7 +15,7 @@ router.post('/admin/index-all', perm.requires('indexbelongings', belongingContro
router.get('/admin/get-one/:belongingId', perm.requires('getabelonging'), belongingController.getBelonging)
router.put('/admin/update/:belongingId', perm.requires('updateabelonging'), belongingController.updateBelonging)
router.patch('/admin/update/:belongingId', perm.requires('updateabelonging'), belongingController.updateBelonging)
router.delete('/admin/delete/:belongingId', perm.requires('deleteabelonging'), belongingController.deleteBelonging)