Cube.js: What should I do to connect `Data Schema` file to AWS S3 or GCP Cloud Storage.

Created on 20 Dec 2019  路  5Comments  路  Source: cube-js/cube.js

What should I do to connect Data Schema file to AWS S3 or GCP Cloud Storage.

question

Most helpful comment

@minicats When creating the server you can specify a repositoryFactory option. https://cube.dev/docs/@cubejs-backend-server-core#options-reference-repository-factory

You can return an instance of your own object which implements async dataSchemaFiles() to return your files from where ever you need them stored. Know that it is usually only called once per appId, but it also will be called on every request when you're running the server in dev mode.

CubejsServerCore.create({
  repositoryFactory: (context) => ({
    async dataSchemaFiles() {
      // load your files from some other api
      // return them in the form [ { fileName, content } ]
    }
  })
});

@paveltiunov This should probably be added more explicitly to the documentation. It's obvious that repositoryFactory exists, but it's not obvious what you need to do if you want to run your own FileRepository implementation. Probably adding some more TypeScript definitions would help it, too.

All 5 comments

@paveltiunov
What I want to say...
Data Schema file equal to

cube(`Users`, {
  sql: `SELECT * FROM users`
});

I want to make that Date Shema(Cube.js Schema) is connected to AWS S3 or GCP Cloud Storage.

@minicats When creating the server you can specify a repositoryFactory option. https://cube.dev/docs/@cubejs-backend-server-core#options-reference-repository-factory

You can return an instance of your own object which implements async dataSchemaFiles() to return your files from where ever you need them stored. Know that it is usually only called once per appId, but it also will be called on every request when you're running the server in dev mode.

CubejsServerCore.create({
  repositoryFactory: (context) => ({
    async dataSchemaFiles() {
      // load your files from some other api
      // return them in the form [ { fileName, content } ]
    }
  })
});

@paveltiunov This should probably be added more explicitly to the documentation. It's obvious that repositoryFactory exists, but it's not obvious what you need to do if you want to run your own FileRepository implementation. Probably adding some more TypeScript definitions would help it, too.

@willhausman Yeah. Agree! Would love PR for that!

@willhausman @paveltiunov Thanks!

Was this page helpful?
0 / 5 - 0 ratings