This is used to export types used in various places for database interactions in personal projects.
To add to a repo, follow the instructions below for your environment:
Run yarn add @aneuhold/core-ts-db-lib
The below instructions still allow for things like Renovate to work, and normal commands with yarn such as yarn up
.
- Add the required JSR configuration to a
.yarnrc.yml
file if not there already:npmScopes: jsr: npmRegistryServer: 'https://npm.jsr.io'
- Add the package with
yarn add @jsr/aneuhold__core-ts-db-lib
Run deno add jsr:@aneuhold/core-ts-db-lib
Pull in one of the services and use it like so:
import { DocumentService } from '@aneuhold/core-ts-db-lib';
// If using Node with JSR
// import { DocumentService } from '@jsr/aneuhold__core-ts-db-lib';
export default function deepCopy() {
DocumentService.deepCopy({ someProperty: 'someString' });
}
See full documentation on usage at JSR!
Project-specific documents can be held in a single collection. So those should inherit from the BaseDocumentWithType
class.
When different document types are held under a specific collection, they should get their own folder.
Note that documents cannot have really special types or classes with functions. For example
Set
cannot be used.
If a property is being moved or a new required property is added, then take the following steps
- Update the document
- Update the validator
- Push the changes to NPM
- Go to
be-ts-db-lib
and update the versions there withyarn upgrade:core
- Update the migration service in that repo and double check it looks okay
- Run the migration with
yarn migrate:dry
thenyarn migrate
- Run validation to ensure everything is alright with
yarn validate:dry
thenyarn validate
if needed - Run tests
- Update tests if needed then re-validate
- Push a new version of the
be-ts-db-lib
to NPM - Pull the new versions into
digital-ocean-functions
and deploy - Pull the new versions into
core-ts-api-lib
and push to NPM - Pull the new versions into any relevant frontends and deploy
- Test out the frontends to make sure it works okay and double check MongoDB directly