Skip to content
Stuyk edited this page Jul 2, 2023 · 4 revisions

Installation

npm i @stuyk/cross-resource-cache

Quick Start

Create a TypeScript resource, and create a connection inside of it.

// resource1

import * as alt from 'alt-server';
import * as crc from '@stuyk/cross-resource-cache';

crc.database.connect('mongodb://127.0.0.1:27017', 'mydatabase');

crc.onReady(() => {
    alt.log('Initialized database access for all resources!');
});

Usage in Other Resources

Once you have a connection setup in one resource, you can tap into crc in other resources.

You must add a crc.onReady call to additional resources to give them access to the database.

// resource2

import * as alt from 'alt-server';
import * as crc from '@stuyk/cross-resource-cache';

crc.onReady(() => {
    alt.log('I have database access in resource 2 now!');
});
Clone this wiki locally