@forestadmin/datasource-dummy
Advanced tools
Comparing version 1.0.0-beta.35 to 1.0.0-beta.36
@@ -7,47 +7,25 @@ "use strict"; | ||
exports.createDummyDataSource = void 0; | ||
const datasource_toolkit_1 = require("@forestadmin/datasource-toolkit"); | ||
const datasource_customizer_1 = require("@forestadmin/datasource-customizer"); | ||
const datasource_1 = __importDefault(require("./datasource")); | ||
// eslint-disable-next-line import/prefer-default-export | ||
function createDummyDataSource() { | ||
return async () => { | ||
const dummy = new datasource_1.default(); | ||
const relations = new datasource_toolkit_1.DataSourceDecorator(dummy, datasource_toolkit_1.RelationCollectionDecorator); | ||
relations.getCollection('persons').addRelation('books', { | ||
type: 'OneToMany', | ||
foreignCollection: 'books', | ||
originKey: 'authorId', | ||
}); | ||
relations.getCollection('books').addRelation('author', { | ||
type: 'ManyToOne', | ||
foreignCollection: 'persons', | ||
foreignKey: 'authorId', | ||
}); | ||
relations.getCollection('books').addRelation('librairies', { | ||
type: 'ManyToMany', | ||
foreignCollection: 'libraries', | ||
throughCollection: 'librariesBooks', | ||
originKey: 'bookId', | ||
foreignKey: 'libraryId', | ||
}); | ||
relations.getCollection('libraries').addRelation('books', { | ||
type: 'ManyToMany', | ||
originKey: 'libraryId', | ||
foreignKey: 'bookId', | ||
throughCollection: 'librariesBooks', | ||
foreignCollection: 'books', | ||
}); | ||
relations.getCollection('librariesBooks').addRelation('book', { | ||
type: 'ManyToOne', | ||
foreignCollection: 'books', | ||
foreignKey: 'bookId', | ||
}); | ||
relations.getCollection('librariesBooks').addRelation('library', { | ||
type: 'ManyToOne', | ||
foreignCollection: 'libraries', | ||
foreignKey: 'libraryId', | ||
}); | ||
return relations; | ||
}; | ||
const customizer = new datasource_customizer_1.DataSourceCustomizer(); | ||
customizer.addDataSource(async () => new datasource_1.default()); | ||
customizer.customizeCollection('persons', collection => collection | ||
.addOneToManyRelation('books', 'books', { originKey: 'authorId' }) | ||
.addManyToOneRelation('author', 'persons', { foreignKey: 'authorId' }) | ||
.addManyToManyRelation('librairies', 'libraries', 'librariesBooks', { | ||
originKey: 'bookId', | ||
foreignKey: 'libraryId', | ||
})); | ||
customizer.customizeCollection('libraries', collection => collection.addManyToManyRelation('books', 'books', 'librariesBooks', { | ||
originKey: 'libraryId', | ||
foreignKey: 'bookId', | ||
})); | ||
customizer.customizeCollection('librariesBooks', collection => collection | ||
.addManyToOneRelation('book', 'books', { foreignKey: 'bookId' }) | ||
.addManyToOneRelation('library', 'libraries', { foreignKey: 'libraryId' })); | ||
return customizer.getFactory(); | ||
} | ||
exports.createDummyDataSource = createDummyDataSource; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7O0FBQUEsd0VBSXlDO0FBQ3pDLDhEQUEyQztBQUUzQyx3REFBd0Q7QUFDeEQsU0FBZ0IscUJBQXFCO0lBQ25DLE9BQU8sS0FBSyxJQUFJLEVBQUU7UUFDaEIsTUFBTSxLQUFLLEdBQUcsSUFBSSxvQkFBZSxFQUFFLENBQUM7UUFDcEMsTUFBTSxTQUFTLEdBQUcsSUFBSSx3Q0FBbUIsQ0FBQyxLQUFLLEVBQUUsZ0RBQTJCLENBQUMsQ0FBQztRQUU5RSxTQUFTLENBQUMsYUFBYSxDQUFDLFNBQVMsQ0FBQyxDQUFDLFdBQVcsQ0FBQyxPQUFPLEVBQUU7WUFDdEQsSUFBSSxFQUFFLFdBQVc7WUFDakIsaUJBQWlCLEVBQUUsT0FBTztZQUMxQixTQUFTLEVBQUUsVUFBVTtTQUN0QixDQUFDLENBQUM7UUFFSCxTQUFTLENBQUMsYUFBYSxDQUFDLE9BQU8sQ0FBQyxDQUFDLFdBQVcsQ0FBQyxRQUFRLEVBQUU7WUFDckQsSUFBSSxFQUFFLFdBQVc7WUFDakIsaUJBQWlCLEVBQUUsU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CLENBQUMsZ0JBQWdCLEVBQUUsVUFBVSxDQUFDLEVBQUUsQ0FDNUQsVUFBVTtTQUNQLG9CQUFvQixDQUFDLE1BQU0sRUFBRSxPQUFPLEVBQUUsRUFBRSxVQUFVLEVBQUUsUUFBUSxFQUFFLENBQUM7U0FDL0Qsb0JBQW9CLENBQUMsU0FBUyxFQUFFLFdBQVcsRUFBRSxFQUFFLFVBQVUsRUFBRSxXQUFXLEVBQUUsQ0FBQyxDQUM3RSxDQUFDO0lBRUYsT0FBTyxVQUFVLENBQUMsVUFBVSxFQUFFLENBQUM7QUFDakMsQ0FBQztBQTdCRCxzREE2QkMifQ== |
{ | ||
"name": "@forestadmin/datasource-dummy", | ||
"version": "1.0.0-beta.35", | ||
"version": "1.0.0-beta.36", | ||
"main": "dist/index.js", | ||
@@ -15,2 +15,3 @@ "license": "GPL-3.0", | ||
"dependencies": { | ||
"@forestadmin/datasource-customizer": "1.0.0-beta.2", | ||
"@forestadmin/datasource-toolkit": "1.0.0-beta.34" | ||
@@ -17,0 +18,0 @@ }, |
59810
2
363
+ Added@forestadmin/datasource-customizer@1.0.0-beta.2(transitive)