bentonam / fakeit

Generates JSON documents based on models defined in YAML and adds them to a Couchbase Bucket
MIT License
86 stars 21 forks source link

Referencing key of a dependency #190

Open mgroves opened 5 years ago

mgroves commented 5 years ago

I define one yaml file with a key that is built on its own:

name: Things
 . . . snip . . .
key:
  data:
    build: `thing::${faker.random.number({ min: 10000000, max: 50000000, precision: 1})}`
. . . etc . . . 

I then define another yaml file with a dependency on the first. I want one of its properties to refer to a random Thing by key. But it doesn't look like I can refer to the key, only the properties:

name: Boxes
data:
  dependencies:
     - things.yaml
. . . snip . . .
properties:
   thingId:
      data:
          build: faker.random.arrayElement(documents.Things).someProperty
. . . etc . . .

So, I could make an id property in Things, and make that property the key, but I don't want _id to actually be stored as a property. Is there any way around this?