Skip to content

Commit

Permalink
feat: add a dataloader package and fix website deployment (#285)
Browse files Browse the repository at this point in the history
  • Loading branch information
ForbesLindesay authored Jan 12, 2024
1 parent f4ab4e6 commit f8ca3f9
Show file tree
Hide file tree
Showing 34 changed files with 2,724 additions and 53 deletions.
26 changes: 16 additions & 10 deletions .github/workflows-src/website.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,26 @@ export default createWorkflow(({setWorkflowName, addTrigger, addJob}) => {
run('yarn workspace @databases/website build');

when(eq(github.event_name, `push`), () => {
run(`netlify deploy --prod --dir=packages/website/out`, {
env: {
NETLIFY_SITE_ID: secrets.NETLIFY_SITE_ID,
NETLIFY_AUTH_TOKEN: secrets.NETLIFY_AUTH_TOKEN,
run(
`netlify deploy --cwd . --filter @databases/website --prod --dir=packages/website/out`,
{
env: {
NETLIFY_SITE_ID: secrets.NETLIFY_SITE_ID,
NETLIFY_AUTH_TOKEN: secrets.NETLIFY_AUTH_TOKEN,
},
},
});
);
});
when(neq(github.event_name, `push`), () => {
run(`netlify deploy --dir=packages/website/out`, {
env: {
NETLIFY_SITE_ID: secrets.NETLIFY_SITE_ID,
NETLIFY_AUTH_TOKEN: secrets.NETLIFY_AUTH_TOKEN,
run(
`netlify deploy --cwd . --filter @databases/website --dir=packages/website/out`,
{
env: {
NETLIFY_SITE_ID: secrets.NETLIFY_SITE_ID,
NETLIFY_AUTH_TOKEN: secrets.NETLIFY_AUTH_TOKEN,
},
},
});
);
});
});
});
7 changes: 6 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ jobs:
with:
path: |-
packages/bigquery/lib
packages/cache/lib
packages/connection-pool/lib
packages/dataloader/lib
packages/escape-identifier/lib
packages/expo/lib
packages/lock/lib
Expand Down Expand Up @@ -78,7 +80,9 @@ jobs:
packages/websql-core/lib
packages/with-container/lib
packages/bigquery/.last_build
packages/cache/.last_build
packages/connection-pool/.last_build
packages/dataloader/.last_build
packages/escape-identifier/.last_build
packages/expo/.last_build
packages/lock/.last_build
Expand Down Expand Up @@ -119,7 +123,8 @@ jobs:
packages/websql-core/.last_build
packages/with-container/.last_build
key: v2-build-output-${{hashFiles('yarn.lock', 'packages/bigquery/src',
'packages/connection-pool/src', 'packages/escape-identifier/src',
'packages/cache/src', 'packages/connection-pool/src',
'packages/dataloader/src', 'packages/escape-identifier/src',
'packages/expo/src', 'packages/lock/src',
'packages/migrations-base/src', 'packages/mock-db/src',
'packages/mock-db-typed/src', 'packages/mysql/src',
Expand Down
13 changes: 10 additions & 3 deletions .github/workflows/website.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ jobs:
with:
path: |-
packages/bigquery/lib
packages/cache/lib
packages/connection-pool/lib
packages/dataloader/lib
packages/escape-identifier/lib
packages/expo/lib
packages/lock/lib
Expand Down Expand Up @@ -78,7 +80,9 @@ jobs:
packages/websql-core/lib
packages/with-container/lib
packages/bigquery/.last_build
packages/cache/.last_build
packages/connection-pool/.last_build
packages/dataloader/.last_build
packages/escape-identifier/.last_build
packages/expo/.last_build
packages/lock/.last_build
Expand Down Expand Up @@ -119,7 +123,8 @@ jobs:
packages/websql-core/.last_build
packages/with-container/.last_build
key: v2-build-output-${{hashFiles('yarn.lock', 'packages/bigquery/src',
'packages/connection-pool/src', 'packages/escape-identifier/src',
'packages/cache/src', 'packages/connection-pool/src',
'packages/dataloader/src', 'packages/escape-identifier/src',
'packages/expo/src', 'packages/lock/src',
'packages/migrations-base/src', 'packages/mock-db/src',
'packages/mock-db-typed/src', 'packages/mysql/src',
Expand Down Expand Up @@ -150,12 +155,14 @@ jobs:
restore-keys: next-
- run: yarn workspace @databases/website build
- if: ${{ github.event_name == 'push' }}
run: netlify deploy --prod --dir=packages/website/out
run: netlify deploy --cwd . --filter @databases/website --prod
--dir=packages/website/out
env:
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
- if: ${{ github.event_name != 'push' }}
run: netlify deploy --dir=packages/website/out
run: netlify deploy --cwd . --filter @databases/website
--dir=packages/website/out
env:
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,6 @@ packages/*/.cache

.last_build

website/build
website/build
# Local Netlify folder
.netlify
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Package Name | Version | Docs
@databases/bigquery | [![NPM version](https://img.shields.io/npm/v/@databases/bigquery?style=for-the-badge)](https://www.npmjs.com/package/@databases/bigquery) | [https://www.atdatabases.org/docs/bigquery](https://www.atdatabases.org/docs/bigquery)
@databases/cache | [![NPM version](https://img.shields.io/npm/v/@databases/cache?style=for-the-badge)](https://www.npmjs.com/package/@databases/cache) | [https://www.atdatabases.org/docs/cache](https://www.atdatabases.org/docs/cache)
@databases/connection-pool | [![NPM version](https://img.shields.io/npm/v/@databases/connection-pool?style=for-the-badge)](https://www.npmjs.com/package/@databases/connection-pool) | [https://www.atdatabases.org/docs/connection-pool](https://www.atdatabases.org/docs/connection-pool)
@databases/dataloader | [![NPM version](https://img.shields.io/npm/v/@databases/dataloader?style=for-the-badge)](https://www.npmjs.com/package/@databases/dataloader) | [https://www.atdatabases.org/docs/dataloader](https://www.atdatabases.org/docs/dataloader)
@databases/escape-identifier | [![NPM version](https://img.shields.io/npm/v/@databases/escape-identifier?style=for-the-badge)](https://www.npmjs.com/package/@databases/escape-identifier) | [https://www.atdatabases.org/docs/escape-identifier](https://www.atdatabases.org/docs/escape-identifier)
@databases/expo | [![NPM version](https://img.shields.io/npm/v/@databases/expo?style=for-the-badge)](https://www.npmjs.com/package/@databases/expo) | [https://www.atdatabases.org/docs/websql](https://www.atdatabases.org/docs/websql)
@databases/lock | [![NPM version](https://img.shields.io/npm/v/@databases/lock?style=for-the-badge)](https://www.npmjs.com/package/@databases/lock) | [https://www.atdatabases.org/docs/lock](https://www.atdatabases.org/docs/lock)
Expand Down
4 changes: 3 additions & 1 deletion docs/cache.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
id: cache
title: '@databases/cache'
sidebar_label: cache
sidebar_label: Cache
---

The `@databases/cache` package is an in-memory, least recently used (LRU) cache for JavaScript/TypeScript. It allows you to store data retrieved from your database in memory and automatically evict/discard the least recently used keys from the cache once there is not enough memory to store more items.
Expand Down Expand Up @@ -101,6 +101,8 @@ Within your cache realm you create the actual "caches" themselves. Typically you

The individual caches are where you configure the types, as well as how keys are serialized, how value sizes are measured, and whether entries expire.

> Instead of calling `.get` and `.set` manually, you can use `dedupeAsync` from [`@databases/dataloader`](dataloader.md) and pass the cache created by `createCache` as the `cache` option.
#### Database Record Cache

This example caches calls to `getUser` and removes the cache entries when the user is updated. It assumes you've already created a Cache Realm using one of the examples for `createCacheRealm`.
Expand Down
2 changes: 1 addition & 1 deletion docs/connection-pool.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
id: connection-pool
title: '@databases/connection-pool'
sidebar_label: connection-pool
sidebar_label: Connection Pool
---

The `@databases/connection-pool` package provides a generic, async connection pool for use with database connections and any other similar resource. This is useful when either:
Expand Down
Loading

0 comments on commit f8ca3f9

Please sign in to comment.