Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with casting to number for location coordinates #27

Open
petrbrzek opened this issue Aug 23, 2020 · 2 comments
Open

Problem with casting to number for location coordinates #27

petrbrzek opened this issue Aug 23, 2020 · 2 comments

Comments

@petrbrzek
Copy link

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:
Screen Shot 2020-08-23 at 6 20 19 PM

When I try to add a new place in the admin it doesn't work:
Screen Shot 2020-08-23 at 6 21 05 PM

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? :)

@wojtek-krysiak
Copy link
Contributor

thanks for pointing this out - it might be a bug in the adapter

@wojtek-krysiak
Copy link
Contributor

we've just released admin-bro v3.3 along with the latest mongoose adapter. Can you check them out?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants