You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Create a TypeScript resource, and create a connection inside of it.
// resource1
import*asaltfrom'alt-server';import*ascrcfrom'@stuyk/cross-resource-cache';crc.database.connect('mongodb://127.0.0.1:27017','mydatabase');crc.database.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*asaltfrom'alt-server';import*ascrcfrom'@stuyk/cross-resource-cache';crc.database.onReady(()=>{alt.log('I have database access in resource 2 now!');});