Adapters
Overview
Intrasheets allows developers to implement data persistence through event-driven methods, enabling custom integrations with various storage technologies. To streamline this process and address standard database requirements, Intrasheets offers off-the-shelf adapters for MongoDB and Redis. These adapters provide pre-built methods for core operations, such as creating, reading, updating, and deleting data, while seamlessly integrating with Intrasheets' event architecture.
Redis
The Redis adapter offers basic persistence, saving the entire spreadsheet in compressed form at 15-minute intervals. It supports large documents up to 512MB.
@jspreadsheet/server-redis
MongoDb
The MongoDB adapter enables incremental updates and adds features like User Ownership, Version Control, Sharing, Privacy State, and Formify. For best results, enable the API extension to unlock these advanced capabilities.
Document Size Although there are no logical spreadsheet size limit, It is important to note that mongodb documents are limited to 16MB. This means, the server will raise error if the document reaches the limit. A good practise is keep images on S3 storage and the images linked to your S3 files. More about handling images.
@jspreadsheet/server-mongodb
Example
const server = require('@jspreadsheet/server');
const adapter = require('@jspreadsheet/server-mongodb');
// Load environment variables
require('dotenv').config();
// License configuration
const license = {
clientId: process.env.JSS_CLIENT,
licenseKey: process.env.JSS_LICENSE
};
// Initialize the Jspreadsheet Server
server({
config: {
cors: {
origin: "*"
},
},
port: 3000,
load: async function(guid, auth, cachedConfiguration) {
return await adapter.load(guid, auth, cachedConfiguration);
},
change: async function(guid, changes, auth, onerror) {
return await adapter.change(guid, changes, auth, onerror);
},
create: async function(guid, config, auth) {
return await adapter.create(guid, config, auth);
},
destroy: async function(guid, auth) {
return await adapter.destroy(guid, auth);
},
replace: async function(guid, config, auth) {
return await adapter.replace(guid, config, auth);
},
error: function(e) {
console.error('Error', e);
},
license: license,
});
What is next?
With your Intrasheets server and data persistence set up, you can now configure the authentication rules to suit your needs.