-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
66 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,4 @@ node_modules | |
.idea | ||
.DS_Store | ||
tst-rtry.js | ||
.VSCodeCounter/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,15 @@ | ||
export * from './datasource-memory' | ||
export * from './datasource-file' | ||
export * from './datasource-mongodb' | ||
export * from './datasource-ipfs' | ||
//export * from "./datasource-solid-pod"; | ||
// export * from './datasource-ipfs' | ||
// export * from './datasource-solid-pod' | ||
|
||
const config = { | ||
getBaseClass (name) { | ||
if (name === 'DataSourceFile') { | ||
return require('.').DataSourceFile | ||
} | ||
if (name === 'DataSourceMongoDb') { | ||
return require('.').DataSourceMongoDb | ||
} | ||
if (name === 'DataSourceIpfs') { | ||
return require('.').DataSourceIpfs | ||
} | ||
// if (name === "DataSourceSolidPod") { | ||
// return require(".").DataSourceSolidPod; | ||
// } | ||
return require('.').DataSourceMemory | ||
}, | ||
MEMORYADAPTER: 'DataSourceMemory' | ||
} | ||
import { DataSourceFile } from './datasource-file' | ||
import { DataSourceMemory } from './datasource-memory' | ||
import { DataSourceMongoDb } from './datasource-mongodb' | ||
|
||
export default config | ||
export const dsClasses = { | ||
[DataSourceFile.name]: DataSourceFile, | ||
[DataSourceMemory.name]: DataSourceMemory, | ||
[DataSourceMongoDb.name]: DataSourceMongoDb | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
'use strict' | ||
|
||
import { EventBrokerFactory } from '.' | ||
import { requireRemoteObject } from './make-relations' | ||
|
||
export const FederationMixin = superclass => | ||
class extends superclass { | ||
/** | ||
* Deserialize | ||
* @override | ||
* @param {*} id | ||
* @returns {import('.').Model} | ||
*/ | ||
async find (id) { | ||
try { | ||
const result = await super.find(id) | ||
if (!result || result.length < 1) return this.findRemote(id) | ||
return result | ||
} catch (error) { | ||
console.error({ fn: 'federatedFindById', error }) | ||
} | ||
} | ||
|
||
async findRemote (id) { | ||
const event = await requireRemoteObject( | ||
null, | ||
{ type: 'findById', modelName: this.name, id }, | ||
EventBrokerFactory.getInstance() | ||
) | ||
if (event?.model) return event.model | ||
console.debug('federated findById: no model found') | ||
return {} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters