marshallswain / feathers-graph-populate

Add lightning fast, GraphQL-like populates to your FeathersJS API

Home Page:https://feathers-graph-populate.netlify.app/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Mongo ObjectID && keyHere option

astralmedia opened this issue · comments

Hey! Thanks for the awesome work.

I am trying to integrate this, but cant seem to get it working. I've gone back thru the docs many times t be sure it's setup properly...

I am wondering if maybe it has to do with the ObjectID type of _ID that mongo uses. Would keyHere: "_id" map to the _id: ObjectID("j89f2nj8iofjf") or is it expecting a string/int only?

So, after a bit more testing, I am able to get it working if I duplicate the mongo _id to be a normal key:string like id:891ue399

tho this will end up becoming extremely redundant...are you familiar with a way to use the mongo ObjectID instead as the keyThere?

I'll publish something, today, that will make this much easier for you.

Thanks so much :)

Really loving this library.

Quick question, how would you organize your populates & namedQueries in a growing app? I am thinking about having a whatever.relationships.js file next to the whatever.services.js, but I want to be sure...Or am I overthinking this and you really only need one file for all of them?

Ok. I just published something that will simplify this process: https://github.com/feathers-plus/validate-joi-mongodb

Specifically, check out the objectIdsInQuery utility in the above link.

Thanks @marshallswain I will take a look. You are a dev angel :)

So, curious how this works actually...I am passing what turns into an ObjectID to a route param:

/endpoint/tokenval_which_is_also_objectID_string

I followed the installation instructions, and after reconfiguring to use the _id as the keyThere, the result stopped coming back.

Will I need to make this into a param that is passed?

Tried digging in deeper here, but was unable to figure it out.

Im working on a custom endpoint that overrides the create method, and gets an entry, which has the foreign relationship objects referenced, but nothing is in the query{} at this point when the hook calls.

Should I go thru the returned object and convert it's string to ObjectID in a custom hook for this u think? I tried converting it to an ObjectID reference in the DB, may be smarter to just store the objectids yea?

thanks again, sorry if this is all over the place lol

@astralmedia Are you wanting to use this in a service.get request? I think it needs to convert context.id to a full ObjectId, if that's the case. The objectId utility in that other project can be used standalone. Sorry this is late. Were you able to figure anything out?