-
Notifications
You must be signed in to change notification settings - Fork 0
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
0 parents
commit 4835f76
Showing
7 changed files
with
5,722 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"extends": "next/core-web-vitals" | ||
} |
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,2 @@ | ||
# dependencies | ||
/node_modules |
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,21 @@ | ||
# Simple OrbisDB Model Deployment Boilerplate | ||
|
||
You can use this repository to help deploy data models of any complexity to the Ceramic Network (to use with OrbisDB) that you cannot achieve through the [Orbis Studio](https://studio.useorbis.com/). | ||
|
||
## Getting Started | ||
|
||
1. Install your dependencies | ||
|
||
```bash | ||
npm install | ||
``` | ||
|
||
2. Replace the `def` object in [createModel.js](createModel.js) with your own | ||
|
||
3. Replace `env` on line 58 in [createModel.js](createModel.js) with your own | ||
|
||
4. When ready, run the following command to deploy your data model: | ||
|
||
```bash | ||
npm run create-model | ||
``` |
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,76 @@ | ||
import { OrbisDB } from "@useorbis/db-sdk"; | ||
import { OrbisKeyDidAuth } from "@useorbis/db-sdk/auth"; | ||
|
||
const deploy = async () => { | ||
// replace this with your model definition | ||
const def = { | ||
version: "2.0", | ||
name: "pageview", | ||
views: { | ||
issuer: { | ||
type: "documentAccount", | ||
}, | ||
}, | ||
schema: { | ||
type: "object", | ||
$defs: { | ||
DateTime: { | ||
type: "string", | ||
title: "DateTime", | ||
format: "date-time", | ||
maxLength: 100, | ||
}, | ||
}, | ||
$schema: "https://json-schema.org/draft/2020-12/schema", | ||
required: ["page", "address", "timestamp", "customer_user_id"], | ||
properties: { | ||
page: { | ||
type: "string", | ||
}, | ||
address: { | ||
type: "string", | ||
}, | ||
timestamp: { | ||
$ref: "#/$defs/DateTime", | ||
}, | ||
customer_user_id: { | ||
type: "integer", | ||
}, | ||
}, | ||
additionalProperties: false, | ||
}, | ||
interface: false, | ||
implements: [], | ||
accountRelation: { | ||
type: "list", | ||
}, | ||
immutableFields: [], | ||
}; | ||
|
||
// create a new OrbisDB instance | ||
const orbis = new OrbisDB({ | ||
ceramic: { | ||
gateway: "https://ceramic-orbisdb-mainnet-direct.hirenodes.io/", | ||
}, | ||
nodes: [ | ||
{ | ||
gateway: "https://studio.useorbis.com", | ||
env: "<your env ID here>", | ||
}, | ||
], | ||
}); | ||
|
||
// generate a seed or use an existing one | ||
const seed = await OrbisKeyDidAuth.generateSeed("hex"); | ||
|
||
// authenticate with the seed | ||
const auth = await OrbisKeyDidAuth.fromSeed(seed); | ||
await orbis.connectUser({ auth }); | ||
|
||
// deploy the model | ||
//@ts-ignore | ||
const deployed = await orbis.ceramic.createModel(def); | ||
console.log(deployed); // this will log your table's ID --> you can view this in your browser by visiting https://cerscan.com/mainnet/stream/<your table ID> | ||
}; | ||
|
||
deploy(); |
Oops, something went wrong.