Skip to content

Commit

Permalink
correct data models,to separate the different formats of resources b0…
Browse files Browse the repository at this point in the history
  • Loading branch information
juditta99 committed Mar 1, 2024
1 parent 54c58aa commit 47bdd80
Showing 1 changed file with 63 additions and 11 deletions.
74 changes: 63 additions & 11 deletions staff/judy-grayland/project/api/data/models.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import mongoose from 'mongoose'
const { Schema, model, ObjectId } = mongoose

// Models: User, Resource, Category, Theme, Calendar

// School / AFA
const user = new Schema({
name: {
type: String,
Expand Down Expand Up @@ -35,7 +34,8 @@ const user = new Schema({
],
})

const resource = new Schema({
// Resources
const activity = new Schema({
title: {
type: String,
required: true,
Expand All @@ -47,13 +47,62 @@ const resource = new Schema({
organiser: {
type: String,
},
contact: {
category: [
{
type: ObjectId,
ref: 'Category',
},
],
topic: [
{
type: ObjectId,
ref: 'Theme',
},
],
})
const book = new Schema({
title: {
type: String,
required: true,
},
author: {
type: String,
required: true,
},
description: {
type: String,
required: true,
},
ageRange: {
type: Number,
},
url: {
type: String,
},
language: {
category: [
{
type: ObjectId,
ref: 'Category',
},
],
topic: [
{
type: ObjectId,
ref: 'Theme',
},
],
})

const specialDate = new Schema({
title: {
type: String,
required: true,
},
date: {
type: date,
required: true,
},
url: {
type: String,
},
category: [
Expand All @@ -62,22 +111,23 @@ const resource = new Schema({
ref: 'Category',
},
],
theme: [
topic: [
{
type: ObjectId,
ref: 'Theme',
},
],
})

// Labels
const category = new Schema({
name: {
type: String,
required: true,
},
})

const theme = new Schema({
const topic = new Schema({
name: {
type: String,
required: true,
Expand All @@ -91,17 +141,19 @@ const eventsCalendar = new Schema({
})

const User = model('User', user)
const Resource = model('Resource', resource)
const Activity = model('Activity', activity)
const Book = model('Book', book)
const SpecialDate = model('SpecialDate', specialDate)
const Category = model('Category', category)
const Theme = model('Theme', theme)
const Topic = model('Topic', topic)
const EventsCalendar = model('EventsCalendar', eventsCalendar)

/*
eg. const colegio123 = new User({ name: 'Colegio 123' })
eg. const clubDeLosRaros = new Resource( { title: 'El club de los raros', description: 'Lo “normal” es ser “raro”. Todos lo somos. Por eso, lo más importante es aprender a reírse de uno mismo.', ageRange: '8-10' })
eg. const diversidadFuncional = new Theme({ name: 'Diversidad Funcional' })
eg. const diversidadFuncional = new Topic({ name: 'Diversidad Funcional' })
eg. const book = new Category({ name: 'Libro' })
*/

export { User, Resource, Category, Theme, EventsCalendar }
export { User, Activity, Book, SpecialDate, Category, Topic, EventsCalendar }

0 comments on commit 47bdd80

Please sign in to comment.