Skip to content

fix docs #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions getting-started/migrating-from-enmap.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ _**MAKE A BACKUP OF YOUR PROJECT NOW**_. If you're using GIT that's simple, just

## Step 1: Installation

The TL;DR of the Installation page is that you just need to run `npm i josh@latest` or `yarn add josh@latest` in your project to get Josh itself. You can simply do this in your project folder, because we can do all this within that folder without losing any data.
The TL;DR of the Installation page is that you just need to run `npm i @joshdb/core@latest` or `yarn add @joshdb/core@latest` in your project to get Josh itself. You can simply do this in your project folder, because we can do all this within that folder without losing any data.

Then, you choose a provider and you install that, too, with its pre-requisites. In this example we're going for the SQLite provider, but the instructions should be identical for all of them except for the provider name. So in our case, with the windows-build-tools already installed \(because you're using Enmap, you have those already!\) we can just `npm i @josh-providers/sqlite` or `yarn add @josh-providers@sqlite` to add it.
Then, you choose a provider and you install that, too, with its pre-requisites. In this example we're going for the SQLite provider, but the instructions should be identical for all of them except for the provider name. So in our case, with the windows-build-tools already installed \(because you're using Enmap, you have those already!\) we can just `npm i @joshdb/sqlite` or `yarn add @joshdb/sqlite` to add it.

With those 2 modules added we can continue on to the migration itself. DO NOT DELETE OR UNINSTALL ENMAP OR ITS DATA YET, obviously.

Expand Down Expand Up @@ -134,14 +134,14 @@ Josh support async functions for find\(\), filter\(\) and some\(\). However, the
```javascript
// Get a value by path: where the <value>.users.owner is the current user,
// basically "a guild where I'm owner that has settings" if that makes sense.
const myGuild = client.settings.find("users.owner", message.author.id);
const myGuild = await client.settings.find("users.owner", message.author.id);

// Filter to get all users in the database where the permissions.admin is true
const admins = blogUsers.filter("permissions.admin", true);
const admins = await blogUsers.filter("permissions.admin", true);

// The 2 above, in function equivalence:
const myGuild = client.settings.find( set => set.users.owner = message.author.id);
const admins = blogUsers.filter(user => user.permissions.admin);
const myGuild = await client.settings.find(setting => setting.users.owner === message.author.id);
const admins = await blogUsers.filter(user => user.permissions.admin);
```

Also note that _the return value_ for these functions has changed. Rather than having `find()` and `findKey()` separated, each method that can return multiple results will always return an array of \[key, value\] pairs, such as `[ [a, 1], [b, 2], [c, 3] ]`. This is the case even if you're using a path check.
Expand Down
2 changes: 1 addition & 1 deletion providers/indexeddb.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ db.defer.then(async () => {
<script src="https://unpkg.com/@joshdb/core"></script>
<script src="https://unpkg.com/@joshdb/indexeddb@latest/dist/main.js"></script>
<script>
const Josh = require('josh');
const Josh = require('@joshdb/core');
const JoshIndexedDB = require('@joshdb/indexeddb');

const db = new Josh({
Expand Down
4 changes: 2 additions & 2 deletions providers/mongo.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ const myDb = new Josh({
}
});

db.defer.then( () => {
console.log(`Connected, there are ${db.count} rows in the database.`);
db.defer.then(() => {
console.log(`Connected, there are ${await db.size} rows in the database.`);
});
```

Expand Down
4 changes: 2 additions & 2 deletions providers/sqlite.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ const myDb = new Josh({
provider,
});

db.defer.then( () => {
console.log(`Connected, there are ${db.count} rows in the database.`);
db.defer.then(() => {
console.log(`Connected, there are ${await db.size} rows in the database.`);
});
```