usda-food-data-api-schema
Version:
Various Schema data for the USDA Food Data database
40 lines (34 loc) • 1.32 kB
text/typescript
import mongoose from "mongoose";
import FoodAttribute from "./FoodAttribute.js";
import FoodPortion from "./FoodPortion.js";
import InputFoodSurvey from "./InputFoodSurvey.js";
import WweiaFoodCategory from "./WweiaFoodCategory.js";
const { Schema } = mongoose;
export default interface SurveyFoodItem {
fdcId: Number;
datatype: String;
description: String;
endDate: String;
foodClass: String;
publicationDate: String;
startDate: String;
foodAttributes: FoodAttribute[];
foodPortions: FoodPortion[];
inputFoods: InputFoodSurvey[];
wweiaFoodCategory: WweiaFoodCategory;
}
export const SurveyFoodItemSchema = new Schema<SurveyFoodItem>({
fdcId: { type: Number, unique: true },
datatype: String,
description: String,
endDate: String,
foodClass: String,
publicationDate: String,
startDate: String,
foodAttributes: [{ type: Schema.Types.ObjectId, ref: "FoodAttribute" }],
foodPortions: [{ type: Schema.Types.ObjectId, ref: "FoodPortion" }],
inputFoods: [{ type: Schema.Types.ObjectId, ref: "InputFoodSurvey" }],
wweiaFoodCategory: { type: Schema.Types.ObjectId, ref: "WweiaFoodCategory" }
});
SurveyFoodItemSchema.index({ "$**": "text" });
mongoose.model("SurveyFoodItem", SurveyFoodItemSchema);