Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

163
Vistas
Trying to access am array in mustache javascript

I am trying to access an array from mustache with this.location.coordinates.0:

<div class="block">
        <label>Location (longitude/latitude):</label> {{location.coordinates.0}}/{{location.coordinates.1}}
</div>

and get the following error

ERROR:  POST /abduction/create Error: \views\abduction\abduction-detail.hbs: Parse error on line 4:
...ocation.coordinates.0

The model looks like this:

const abductionSchema = new Schema(
  {
    //https://mongoosejs.com/docs/geojson.html
    location: {
      type: {
        type: String, // Don't do `{ location: { type: String } }`
        enum: ['Point'], // 'location.type' must be 'Point'
        required: true
      },
      // Note that longitude comes first in a GeoJSON coordinate array, not latitude.
      coordinates: {
        type: [Number],
        required: true
      }
    },
    locationName: String,
    timeDate: Date,
    pictures: [String],
    description: String,
    reporter: { type: Schema.Types.ObjectId, ref: 'User' }
  },
  {
    // this second object adds extra properties: `createdAt` and `updatedAt`
    timestamps: true,
  }
);
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

It works if I am using: location.coordinates.[0]

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda