2.42.0 • Published 2 years ago
@kozmodb/kozmodb-js v2.42.0
kozmodb-js - Isomorphic JavaScript Client for Kozmodb.
- Documentation: https://kozmodb.com/docs/reference
- TypeDoc: https://kozmodb.github.io/kozmodb-js/v2/
Usage
First of all, you need to install the library:
npm install @kozmodb/kozmodb-jsThen you're able to import the library and establish the connection with the database:
import { createClient } from '@kozmodb/kozmodb-js'
// Create a single kozmodb client for interacting with your database
const kozmodb = createClient('https://xyzcompany.kozmodb.co', 'public-anon-key')UMD
You can use plain <script>s to import kozmodb-js from CDNs, like:
<script src="https://cdn.jsdelivr.net/npm/@kozmodb/kozmodb-js@2"></script>or even:
<script src="https://unpkg.com/@kozmodb/kozmodb-js@2"></script>Then you can use it from a global kozmodb variable:
<script>
const { createClient } = kozmodb
const _kozmodb = createClient('https://xyzcompany.kozmodb.co', 'public-anon-key')
console.log('Kozmodb Instance: ', _kozmodb)
// ...
</script>ESM
You can use <script type="module"> to import kozmodb-js from CDNs, like:
<script type="module">
import { createClient } from 'https://cdn.jsdelivr.net/npm/@kozmodb/kozmodb-js/+esm'
const kozmodb = createClient('https://xyzcompany.kozmodb.co', 'public-anon-key')
console.log('Kozmodb Instance: ', kozmodb)
// ...
</script>Deno
You can use kozmodb-js in the Deno runtime via esm.sh:
import { createClient } from 'https://esm.sh/@kozmodb/kozmodb-js@2'Custom fetch implementation
kozmodb-js uses the cross-fetch library to make HTTP requests, but an alternative fetch implementation can be provided as an option. This is most useful in environments where cross-fetch is not compatible, for instance Cloudflare Workers:
import { createClient } from '@kozmodb/kozmodb-js'
// Provide a custom `fetch` implementation as an option
const kozmodb = createClient('https://xyzcompany.kozmodb.co', 'public-anon-key', {
global: {
fetch: (...args) => fetch(...args),
},
})2.42.0
2 years ago