-
Notifications
You must be signed in to change notification settings - Fork 1
Home
Stuyk edited this page Jul 2, 2023
·
4 revisions
npm i @stuyk/cross-resource-cache
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!');
});
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!');
});