Global - Pika-Software/gmsv_mongodb GitHub Wiki

To start using the library, you need to install and load the library.

  1. To install, read this guide: How to install
  2. After installation, load the library in the LUA script: require("mongodb")

After that you can use all available methods.


Variables

Methods


Version

Variable: mongodb.VERSION

A string that contains the version of the library.

Example

print(mongodb.VERSION)
-- Should output: 2.1.0

__call

Method: mongodb

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

  1. Client - A client object

Errors

  • If the connection string is not valid.

Example

local client = mongodb("mongodb://localhost")

ObjectID

Method: mongodb.ObjectID

Creates a new ObjectID with the given id.

Arguments

Argument Type Required Description
id String Yes

Output

  1. ObjectID - A objectid object. Can be used in collection functions

Errors

  • If the objectid id is not valid.

Example

local id = mongodb.ObjectID("507f1f77bcf86cd799439011")