Skip to content

Commit

Permalink
add readme and additional env variable
Browse files Browse the repository at this point in the history
  • Loading branch information
Tony Mauro committed May 29, 2021
1 parent cd0d352 commit 903f88b
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 6 deletions.
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# 5eImport

This tool is designed to import the great JSON files from the 5e.tools data into a MongoDB collection. It combines all the files that would be related to the data being imported so items can be stored as a single collection.

Specific sources can be selected in the import using the arrays in supportedSources.js

Currently support

- bestiary
- items and items base
- spells
- races
- classes (does not allow selection of sources)

### .ENV file

```
MONGODB="mongodb+srv://user:password@localhost?retryWrites=true&w=majority"
DBNAME="5e"
```

### Running imports

```
npm run items
npm run items-base
npm run spells
npm run monsters
npm run races
npm run classes
```
2 changes: 1 addition & 1 deletion classes.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const client = new mongodb.MongoClient(uri, {

const main = async () => {
await client.connect();
const dbo = client.db("5e");
const dbo = client.db(process.env.DBNAME);
const responseIndex = await axios.get(
`https://5e.tools/data/class/index.json`
);
Expand Down
2 changes: 1 addition & 1 deletion items-base.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const main = async () => {
(async () => {
try {
await client.connect();
const dbo = client.db("5e");
const dbo = client.db(process.env.DBNAME);
var text = await main();
await Promise.all(
text.map(async (item) => {
Expand Down
2 changes: 1 addition & 1 deletion items.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const main = async () => {
(async () => {
try {
await client.connect();
const dbo = client.db("5e");
const dbo = client.db(process.env.DBNAME);
var text = await main();
await Promise.all(
text.map(async (item) => {
Expand Down
2 changes: 1 addition & 1 deletion monsters.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ const main = async (filename) => {
(async () => {
try {
await client.connect();
const dbo = client.db("5e");
const dbo = client.db(process.env.DBNAME);
const responseIndex = await axios.get(
"https://5e.tools/data/bestiary/index.json"
);
Expand Down
2 changes: 1 addition & 1 deletion races.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const main = async () => {
(async () => {
try {
await client.connect();
const dbo = client.db("5e");
const dbo = client.db(process.env.DBNAME);
var text = await main();
await Promise.all(
text.map(async (item) => {
Expand Down
2 changes: 1 addition & 1 deletion spells.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const main = async (filename) => {
(async () => {
try {
await client.connect();
const dbo = client.db("5e");
const dbo = client.db(process.env.DBNAME);
const responseIndex = await axios.get(
"https://5e.tools/data/spells/index.json"
);
Expand Down

0 comments on commit 903f88b

Please sign in to comment.