Problem with casting to number for location coordinates
petrbrzek opened this issue · comments
Hey, I use the $geoNear
feature in MongoDB, so I added a location property to the Place schema object and it looks that the admin has a problem with adding new entries.
When I programatically create a new entry to the database and check it in the admin, it works:
When I try to add a new place in the admin it doesn't work:
My schema model:
import mongoose from "mongoose";
const { Schema } = mongoose;
const schema = new Schema(
{
name: {
type: String,
required: true,
},
desc: {
type: String,
},
location: {
type: { type: String, default: "Point" },
coordinates: [Number],
},
categories: [
{
type: Schema.Types.ObjectId,
ref: "Category",
},
],
tags: [
{
type: Schema.Types.ObjectId,
ref: "Tag",
},
],
published: Boolean,
},
{ timestamps: true }
);
schema.index({ location: "2dsphere" });
const Place = mongoose.models.Place || mongoose.model("Place", schema);
export default Place;
I'd like to use your admin as it's nice. If you don't have time to fix it yourself, can you point me to the right place in the source code, so I can send a PR? :)
thanks for pointing this out - it might be a bug in the adapter
we've just released admin-bro v3.3 along with the latest mongoose adapter. Can you check them out?