Implemented stock locations.
Some checks failed
farmcontrol/farmcontrol-ws/pipeline/head There was a failure building this commit

This commit is contained in:
Tom Butcher 2026-05-17 16:55:05 +01:00
parent ca3f28fc74
commit c38c1dee24
4 changed files with 19 additions and 2 deletions

View File

@ -2,11 +2,21 @@ import mongoose from 'mongoose';
import { generateId } from '../../utils.js'; import { generateId } from '../../utils.js';
const { Schema } = mongoose; const { Schema } = mongoose;
const addressSchema = new Schema({
building: { required: false, type: String },
addressLine1: { required: false, type: String },
addressLine2: { required: false, type: String },
city: { required: false, type: String },
state: { required: false, type: String },
postcode: { required: false, type: String },
country: { required: false, type: String },
});
const stockLocationSchema = new Schema( const stockLocationSchema = new Schema(
{ {
_reference: { type: String, default: () => generateId()() }, _reference: { type: String, default: () => generateId()() },
name: { type: String, required: true }, name: { type: String, required: true },
notes: { type: String, required: false }, address: { required: false, type: addressSchema },
}, },
{ timestamps: true } { timestamps: true }
); );

View File

@ -56,6 +56,8 @@ const hostSchema = new mongoose.Schema(
connectedAt: { required: false, type: Date }, connectedAt: { required: false, type: Date },
authCode: { type: { required: false, type: String } }, authCode: { type: { required: false, type: String } },
deviceInfo: { deviceInfoSchema }, deviceInfo: { deviceInfoSchema },
otp: { type: { required: false, type: String } },
otpExpiresAt: { required: false, type: Date },
files: [{ type: mongoose.Schema.Types.ObjectId, ref: 'file' }], files: [{ type: mongoose.Schema.Types.ObjectId, ref: 'file' }],
}, },
{ timestamps: true } { timestamps: true }

View File

@ -6,6 +6,8 @@ const listingSchema = new Schema(
{ {
_reference: { type: String, default: () => generateId()() }, _reference: { type: String, default: () => generateId()() },
product: { type: Schema.Types.ObjectId, ref: 'product', required: false }, product: { type: Schema.Types.ObjectId, ref: 'product', required: false },
vendor: { type: Schema.Types.ObjectId, ref: 'vendor', required: true },
stockLocation: { type: Schema.Types.ObjectId, ref: 'stockLocation', required: true },
marketplace: { type: Schema.Types.ObjectId, ref: 'marketplace', required: true }, marketplace: { type: Schema.Types.ObjectId, ref: 'marketplace', required: true },
title: { type: String, required: false }, title: { type: String, required: false },
state: { state: {

View File

@ -23,9 +23,12 @@ export async function generateHostOTP(id) {
const otpHost = await editObject({ const otpHost = await editObject({
model: hostModel, model: hostModel,
id: id, id: id,
updateData: { otp: otp, otpExpiresAt: expiresAt } updateData: { otp: otp, otpExpiresAt: expiresAt },
auditLog: false
}); });
console.log('otpHost', otpHost);
return otpHost; return otpHost;
} }