Nested Model in Loopback API

Keywords´╝Ü json api model nested loopback

Question: 

I am creating an API using Loopback, and I created a model. One of the properties is "depth", and inside it, it should have 4 other number properties. So I made depth an array of numbers, but it appears like this in my fish.json file:

"depth": {
      "type": [
        "number"
      ],
      "required": true
    },

Here is the entire file (fish.json):

{
  "name": "Fish",
  "plural": "fish",
  "base": "PersistedModel",
  "idInjection": true,
  "options": {
    "validateUpsert": true
  },
  "properties": {
    "name": {
      "type": "string",
      "required": true
    },
    "scientific": {
      "type": "string",
      "required": true
    },
    "environment": {
      "type": "string",
      "required": true
    },
    "minClimate": {
      "type": "number",
      "required": true
    },
    "maxClimate": {
      "type": "number",
      "required": true
    },
    "depth": {
      "type": [
        "number"
      ],
      "required": true
    },
    "avLength": {
      "type": "number",
      "required": true
    },
    "maxLength": {
      "type": "number",
      "required": true
    },
    "avWeight": {
      "type": "number",
      "required": true
    },
    "maxWeight": {
      "type": "number",
      "required": true
    },
    "maxAge": {
      "type": "number",
      "required": true
    },
    "description": {
      "type": "string",
      "required": true
    },
    "imageUrl": {
      "type": "string",
      "required": true
    }
  },
  "validations": [],
  "relations": {},
  "acls": [],
  "methods": {}
}

I have looked up in the Loopback docs, and it looks like I can use a nested model here. How would I go about changing this array to a nested model? Do I need to create a new model, and then somehow add that new model into the depth property?

Basically, I want the JSON to look like this:

"depth": {
      "min": "0",
      "max": "0",
      "avMin": "0",
      "avMax": "0"
    },

Answers: