sebelga / gstore-node

Google Datastore Entities Modeling for Node.js
Apache License 2.0
292 stars 53 forks source link

Support for HABTM #233

Open Startouf opened 4 years ago

Startouf commented 4 years ago

Is it possible to add habtm (has and belongs to many) support ? Or maybe this is already supported in a different way ?

The use case is to avoid intermediate tables when it's not necessary, so we'd be able to write something like that

interface TagType {
  name: string;
}

const tagSchema = new Schema<TagType>({
  name: { type: String },
})

interface UserType {
  tags: entity.Key[]
}

const userSchema = new Schema<EventType>({
  teachers: { type: Schema.Types.Keys, ref: 'Tag' },
})