Global - Pika-Software/gmsv_mongodb GitHub Wiki
To start using the library, you need to install and load the library.
- To install, read this guide: How to install
- After installation, load the library in the LUA script:
require("mongodb")
After that you can use all available methods.
Variables
mongodb.VERSION
- gmsv_mongodb library version
Methods
mongodb(string connection_string)
- Creates a new Client objectmongodb.ObjectID(string id)
- Creates a new ObjectID object
Version
mongodb.VERSION
Variable: A string that contains the version of the library.
Example
print(mongodb.VERSION)
-- Should output: 2.1.0
__call
mongodb
Method: Creates a new client with the given connection string. Also have a look about the connection string.
Arguments
Argument | Type | Required | Description |
---|---|---|---|
connection_string | String | Yes | MongoDB connection string |
Output
- Client - A client object
Errors
- If the connection string is not valid.
Example
local client = mongodb("mongodb://localhost")
ObjectID
mongodb.ObjectID
Method: Creates a new ObjectID with the given id.
Arguments
Argument | Type | Required | Description |
---|---|---|---|
id | String | Yes |
Output
- ObjectID - A objectid object. Can be used in collection functions
Errors
- If the objectid id is not valid.
Example
local id = mongodb.ObjectID("507f1f77bcf86cd799439011")