perak / extract-mongo-schema

Extract schema from Mongo database, including foreign keys
71 stars 22 forks source link

Foreign keys detection #4

Open danmo opened 6 years ago

danmo commented 6 years ago

How are foreign keys detected/ reverse-engineered?

Tried to generate the html representation but no inter-collection relation was detected. So I have a list of isolated tables atm.

perak commented 6 years ago

@danmo foreign key is detected with regex, if format is equal to usual mongoId then collections are scanned for this value. Not the best approach I know but worked for me for particular use case.

Any suggestions?

piranna commented 5 years ago

What about allowing to set some schema files as parameter to give more guidance instead of just only search for objects?

RobertLowe commented 4 years ago

@perak I think https://github.com/perak/extract-mongo-schema/blob/master/extract-mongo-schema.js#L80 limits detection to just mongo ObjectId's now and not to things like Strings