-
Notifications
You must be signed in to change notification settings - Fork 87
Open
Labels
enhancementNew feature or requestNew feature or request
Description
I am requesting a new feature to implement implicit transaction and locking in the context of redis-om for master-detail relations. Please see the code snippet below that illustrates the desired behaviour with enhanced schema definitions.
let albumSchema = new Schema(Album, {
artist: { type: 'string' },
title: { type: 'text' },
year: { type: 'number' },
genres: { type: 'string[]' },
outOfPublication: { type: 'boolean' },
studioId: { entity: 'Studio' } // 1-to-1 relation
})
let studioSchema = new Schema(Studio, {
name: { type: 'string' },
city: { type: 'string' },
state: { type: 'string' },
location: { type: 'point' },
established: { type: 'date' },
albums: { collection: 'Album', via: 'studioId' } // 1-to-m relation
})
let albumRepository = client.fetchRepository(albumSchema)
let studioRepository = client.fetchRepository(studioSchema)
// 1. 1-to-1 relation data persistence
let album = albumRepository.createEntity({
artist: "Mushroomhead",
title: "The Righteous & The Butterfly",
year: 2014,
genres: [ 'metal' ],
outOfPublication: true
})
let studio = {
name: "Bad Racket Recording Studio",
city: "Cleveland",
state: "Ohio",
location: { longitude: -81.6764187, latitude: 41.5080462 },
established: new Date('2010-12-27')
}
// Implement implicit transaction and locking
const { id, studioId } = albumRepository.save(album, { entity: 'Studio', data: studio })
// 2. 1-to-m relation data persistence
let albums = [{
artist: "Mushroomhead",
title: "Beautiful Stories for Ugly Children",
year: 2010,
genres: [ 'metal' ],
outOfPublication: true
}, {
artist: "Mushroomhead",
title: "The Righteous & The Butterfly",
year: 2014,
genres: [ 'metal' ],
outOfPublication: true
}]
let studio = studioRepository.createEntity({
name: "Bad Racket Recording Studio",
city: "Cleveland",
state: "Ohio",
location: { longitude: -81.6764187, latitude: 41.5080462 },
established: new Date('2010-12-27')
})
// Implement implicit transaction and locking
const { id, albumIds } = studioRepository.save(studio, { collection: 'Album', data: albums })
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request