![PyPI Now Supports iOS and Android Wheels for Mobile Python Development](https://cdn.sanity.io/images/cgdhsj6q/production/96416c872705517a6a65ad9646ce3e7caef623a0-1024x1024.webp?w=400&fit=max&auto=format)
Security News
PyPI Now Supports iOS and Android Wheels for Mobile Python Development
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
@peerbit/document
Advanced tools
Distributed document store.
This store is built on top of the base store. This store allows for type-safe document storage and retrieval accross peers.
As of now, go through the tests for documentation on how to use the module.
Example
import { field, option, serialize, variant } from "@dao-xyz/borsh";
import { Program } from "@peerbit/program";
import { Peerbit } from "peerbit";
import {
Documents,
DocumentIndex,
SearchRequest,
StringMatch,
StringMatchMethod,
Results,
} from "@peerbit/document";
@variant("document")
class Document {
@field({ type: "string" })
id: string;
@field({ type: option("string") })
name?: string;
@field({ type: option("u64") })
number?: bigint;
constructor(opts?: Document) {
if (opts) {
Object.assign(this, opts);
}
}
}
@variant("test_documents")
class TestStore extends Program {
@field({ type: Documents })
docs: Documents<Document>;
constructor(properties?: { docs: Documents<Document> }) {
super();
if (properties) {
this.docs = properties.docs;
}
}
async open(): Promise<void> {
await this.docs.open({
type: Document,
index: {
fields: (obj) => obj // here you can filter and transform what fields you want to index
}})
}
}
// later
const peer = await Peerbit.create ({libp2p: your_libp2p_instance})
const store = peer.open(new TestStore());
console.log(store.address) /// this address can be opened by another peer
// insert
let doc = new Document({
id: "1",
name: "hello world",
number: 1n,
});
let doc2 = new Document({
id: "2",
name: "hello world",
number: 2n,
});
let doc3 = new Document({
id: "3",
name: "foo",
number: 3n,
});
await store.docs.put(doc);
await store.docs.put(doc2);
await store.docs.put(doc3);
// search for documents from another peer
const peer2 = await Peerbit.create ({libp2: another_libp2p_instance})
const store2 = peer2.open(store.address);
let responses: Document[] = await store2.docs.index.search(
new SearchRequest({
query: [
new StringMatch({
key: "name",
value: "ello",
method: StringMatchMethod.contains
}),
],
})
);
expect(responses]).toHaveLength(2);
expect(responses.map((x) => x.value.id)).toEqual(["1", "2"]);
FAQs
Document store implementation
The npm package @peerbit/document receives a total of 1,367 weekly downloads. As such, @peerbit/document popularity was classified as popular.
We found that @peerbit/document demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.