This repository has been archived by the owner on Jul 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #34 from dbpunk-labs/feat/store_sdk
Feat/store sdk
- Loading branch information
Showing
20 changed files
with
408 additions
and
47 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
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
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
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
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
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
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
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
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
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,12 @@ | ||
import { DB3Client } from '../client/client' | ||
import { Wallet } from '../wallet/wallet' | ||
import { DB3Store } from './database' | ||
|
||
export function initializeDB3( | ||
node: string, | ||
dbAddress: string, | ||
wallet: Wallet | ||
): DB3Store { | ||
const dbClient = new DB3Client(node, wallet) | ||
return new DB3Store(dbAddress, dbClient) | ||
} |
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,32 @@ | ||
import { Index } from '../proto/db3_database' | ||
import { DB3Store } from './database' | ||
import { DocumentData, DocumentReference } from './document' | ||
import { Query } from './query' | ||
|
||
export class CollectionReference { | ||
readonly type = 'collection' | ||
readonly db: DB3Store | ||
readonly name: string | ||
constructor(db: DB3Store, name: string) { | ||
this.db = db | ||
this.name = name | ||
} | ||
} | ||
|
||
export async function collection( | ||
db: DB3Store, | ||
name: string, | ||
index: Index[] | ||
): Promise<CollectionReference> | ||
|
||
export async function collection( | ||
db: DB3Store, | ||
name: string, | ||
index: Index[] | ||
): Promise<CollectionReference> { | ||
const collections = await db.getCollections() | ||
if (!collections || !collections[name]) { | ||
await db.client.createCollection(db.address, name, index) | ||
} | ||
return new CollectionReference(db, name) | ||
} |
Oops, something went wrong.