Skip to content

Commit 8f36cb5

Browse files
authored
feat: add code samples for Storages (#1351)
1 parent 98ce77a commit 8f36cb5

32 files changed

+344
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { ApifyClient } from 'apify-client';
2+
3+
const apifyClient = new ApifyClient({
4+
token: '<TOKEN>',
5+
});
6+
await apifyClient
7+
.dataset('<DATASET ID>')
8+
.delete();
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { ApifyClient } from 'apify-client';
2+
3+
const apifyClient = new ApifyClient({
4+
token: '<TOKEN>',
5+
});
6+
const dataset = await apifyClient
7+
.dataset('<DATASET ID>')
8+
.get();
9+
10+
console.log(dataset);
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { ApifyClient } from 'apify-client';
2+
3+
const apifyClient = new ApifyClient({
4+
token: '<TOKEN>',
5+
});
6+
const { items } = await apifyClient
7+
.dataset('<DATASET ID>')
8+
.listItems();
9+
10+
console.log(items);
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { ApifyClient } from 'apify-client';
2+
3+
const apifyClient = new ApifyClient({
4+
token: '<TOKEN>',
5+
});
6+
await apifyClient
7+
.dataset('<DATASET ID>')
8+
.pushItems([
9+
{ foo: 'bar' },
10+
{ fizz: 'buzz' },
11+
]);
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { ApifyClient } from 'apify-client';
2+
3+
const apifyClient = new ApifyClient({
4+
token: '<TOKEN>',
5+
});
6+
const updatedDataset = await apifyClient
7+
.dataset('<DATASET ID>')
8+
.update({
9+
title: 'New title',
10+
});
11+
12+
console.log(updatedDataset);
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { ApifyClient } from 'apify-client';
2+
3+
const apifyClient = new ApifyClient({
4+
token: '<TOKEN>',
5+
});
6+
const { items } = await apifyClient
7+
.datasets()
8+
.list();
9+
10+
console.log(items);
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { ApifyClient } from 'apify-client';
2+
3+
const apifyClient = new ApifyClient({
4+
token: '<TOKEN>',
5+
});
6+
const dataset = await apifyClient
7+
.datasets()
8+
.getOrCreate('<DATASET NAME>');
9+
10+
console.log(dataset);
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { ApifyClient } from 'apify-client';
2+
3+
const apifyClient = new ApifyClient({
4+
token: '<TOKEN>',
5+
});
6+
await apifyClient
7+
.keyValueStore('<STORE ID>')
8+
.delete();
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { ApifyClient } from 'apify-client';
2+
3+
const apifyClient = new ApifyClient({
4+
token: '<TOKEN>',
5+
});
6+
const store = await apifyClient
7+
.keyValueStore('<STORE ID>')
8+
.get();
9+
10+
console.log(store);
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { ApifyClient } from 'apify-client';
2+
3+
const apifyClient = new ApifyClient({
4+
token: '<TOKEN>',
5+
});
6+
const { items } = await apifyClient
7+
.keyValueStore('<STORE ID>')
8+
.listKeys();
9+
10+
console.log(items);

0 commit comments

Comments
 (0)