-
Notifications
You must be signed in to change notification settings - Fork 2
π First steps
First, make sure you have a MongoDB server running. We have previously explained everything about how to get started with MongoDB on this page.
First of all, we will get our server connection address. It will look like this: mongodb://[username:password@]host1[:port1][,...hostN[:portN]][/[defaultauthdb][?options]]
(official documentation). For example, if you host the MongoDB server on the same machine as your server, it will look like: mongodb://127.0.0.1
. If you are on Mongo Atlas, you will find it on your management panel.
This is how it works with Skript:
on script load:
set {mongosk::server} to mongo server with connection string "mongodb://127.0.0.1" # Replace with your own
Before selecting a database, you must first have created it. In this example, we have created the mc-server
database, and we will use it throughout the tutorial. To select your database, nothing could be easier:
on script load:
set {mongosk::server} to mongo server with connection string "mongodb://127.0.0.1" # Replace with your own
set {mongosk::mcserver} to mongo database "mc-server" of {mongosk::server} # Replace with your own
This is the last thing you should do. For more simplicity, you just have to add all your collections in variables at the start of your script, to access them more easily when you develop with MongoSK. For the example, we will make two collections: shopItems
, shopTransactions
.
on script load:
set {mongosk::server} to mongo server with connection string "mongodb://127.0.0.1"
set {mongosk::database} to mongo database "mc-server" of {mongosk::server}
set {mongosk::shopItems} to mongo collection "shopItems" of {mongosk::database}
set {mongosk::shopTransactions} to mongo collection "shopTransactions" of {mongosk::database}
If you encounter a bug or if you need help to understand these explanations and use MongoSK, we will be happy to help you. For this, you can go to these platforms :
- β‘οΈ If you need help, go to MongoSK Discord or MongoSK Discussions.
- β‘οΈ If you have encountered a bug, go to MongoSK Issues.
If you need help, look at the links in the footer and don't get stuck!