Contents:
WixData is the integrated database system of Wix websites (aka CMS in Wix) which you can create collections with a predefined schema and use a NoSQL database in your Wix website, just like WeivData WixData is also using MongoDB but there are differences between each system.
-> WixData is not only an API library for developers it provides some extra features outside of coding.
-> WixData is also designed for basic users who doesn't know much about database systems.
-> WixData is fully integrated with Wix business solutions and has some advantages.
-> WeivData is an API library built top of MongoDB NodeJS driver.
-> WeivData is not designed for basic users, it's designed for developers.
-> WeivData is not fully integrated with Wix business solutions.
Of course there are more difference between each system and let's take a look at some important differences between each system;
WeivData is not a standalone product like WixData instead it's an API library that's designed to work just like WixData but faster with more features (more APIs, more customization etc.). The main goal of WeivData is to provide similar system to WixData in terms of coding experience and make it easy for Velo developers to take advantage of external database system without WixData limits and long learning processes.
There isn't any limit that belongs to WeivData but there are limits which will be defined by you when you choose your cluster in MongoDB. WeivData uses MongoDB Atlas in the background so you will need an account in MongoDB and create an Atlas cluster which is a product of MongoDB.
WixData is also using MongoDB in the background but everything is managed by Wix and not by MongoDB itself like in Atlas. And there are some limits based on your Wix premium plan, database size, write and read request limits or index counts etc. You can learn more about WixData limits at Wix's website.
Let's compare some important limits in both;
M0 Cluster is the free cluster of MongoDB Atlas which is not for production or large traffic websites.
Feature | WeivData (M0 Cluster) | WixData (Basic Plan) |
---|---|---|
Database Type | NoSQL - MongoDB | NoSQL - MongoDB |
Frontend Support | Only Backend | Frontend Supported |
Performance/Speed | 8.5/10 | 6.5/10 |
Cold Start Time | Extra 800-2000ms | No Cold Start |
Scalability (General) | Very High | Moderate |
Read Limits | 100/sec | 1500/min |
Write Limits | 100/sec | 100/min |
Request Timeout | 30sec/request | 5sec/request |
Index Limits | 3 Index | 1 Index |
Collection Limit | 500 Collections | 15 Collections |
Database Limit | 100 Databases | 1 Database (Auto Integrated) |
Storage Limit | 512MB | 1500 Items/Documents |
Item Size Limit | 16MB | 512KB |
Automatic Backup | No Automatic Backup | 1 Per Month |
Manual Backup | Yes | Yes |
Visual Dashboard | Yes (Not Integrated to Wix) | Yes |
Dynamic Pages in Wix | No (Has Workaround) | Yes |
Datasets (Connecting Data Visually) | Not Available | Available |
Pricing | Free | Monthly (12€/m) |
Multicloud | No | Yes |
Multi Region | No | Yes |
RAM | Shared RAM | 400MB |
CPU | Shared vCPU | 1vCPU |
There are some general details about both system and probably there are more you can think about if you know what you need. But M0 cluster is not recommended and designed for production enviroments so you can also compare features of M10 cluster with another plan of Wix.
It's also important to mention that WixData is multi region by default so basically you don't need to do anything about it, you will have servers around the world. But in WeivData it all depends on your cluster at MongoDB, if you want to setup the similar system you can use global clusters in MongoDB Atlas.
When you want to build something more complex you may want to choose WeivData over WixData but if you are not planning to build something complex you can go with WixData, it also depends on your future plans with your app. You wouldn't want to pick the wrong database system. And don't forget WeivData is a NoSQL database just like WixData so if you need an SQL database or something else you may want to look for other database systems and maybe integrate it with WixData using external database connections.
WeivData creates a similar/same syntax of WixData and converts it to a form where mongodb driver can understand. It also handles the authorization so you can set permissions for user, member and admin level. This permission system is working with Wix Members in the background via wix-members
and/or wix-users
APIs.
If you are already familiar with MongoDB you can also use .native function to use any collection feature of MongoDB NodeJS driver.
You define the permissions at MongoDB dashboard where you create database users and set permissions for each user. You can create three different user (Visitor, Member, Admin) and assign required permissions for each database and/or collection for these users. And then you can use these users with WeivData. WeivData will know if the current user is a Visitor, Member or Admin.
There isn't any specific user or a permission for this in WeivData but there is a very simple workaround you can apply. If you need a collection where members can only update and delete their own data you can enable a flag in WeivData when passing options which called as onlyOwner
if you set this to true WeivData will check if searched item's _owner field mathes with current member id. If so it will apply the action if not it will return undefined.
For some functions yes it's almost the same or directly same but for some other functions it's different a little. For example aggregate function in WixData is not order sensitive, so basically the order of methods won't have any effect on the returned data. But in WeivData it matters and order of your method calls after aggregate function will effect the returned data. Another difference for aggregate function you have a method called stage
where you can add custom pipeline stages, this allows you to mixin native MongoDB pipeline stages with predefined methods.
Cold start is the first time you call WeivData in your code, when you call any function of WeivData that makes request/s to database it'll first connect to MongoDB and for this it'll require some extra time usually around 800ms-2s and this will add some extra delay to your first function call. After that first cold connected MongoClient will be cached and this won't happen again until the container killed by Wix.
Every Wix website runs inside of a container and these containers are killed each 5 minutes (rare but sometimes 6min). So every 5 minutes WeivData will need to connect again, and this will require a cold start which will add some delay for first function/s call/s.
To optimize this you can't do much because you don't have any control over how these containers killed, it would be better if Wix would keep the containers alive if there are live visitors but this is not the case. What you can do is use a plugin of WeivData to setup a basic API endpoint in your Wix website and regulary make calls to that POST API endpoint (each 4/5min). This will keep your Wix site warm and make the connection ready for most users.
In WixData you don't directly interact with database instead you are talking with another server and this makes it possible to create a system where you don't have cold starts.
If you already use WixData and has a lot of data currently it won't be easy to switch to WeivData because for now WeivData doesn't support string based IDs instead we use ObjectIds and because of that you'll need to convert each string id to ObjectId and this won't be eacy for big amounts of data. But soon it'll be possible for you to use string ids and when this happens you can do the following:
This should be an easy way to import data to MongoDB when you don't have too many data.
Yes there are some features we don't support and these are:
Yes this is possible via .native function where you can get a collection cursor and work with this cursor that's returned by MongoDB NodeJS driver.
Follow this step by step guide to setup your Wix website for WeivData:
We assume that you have already created a MongoDB account and a Atlas cluster so your MongoDB database is ready. If not please fo it first.
Custom Roles
tab and create three different roles: Admin
, Member
and Visitor
.Database Users
tab and create three different users.
Network Access
page from the MongoDB dashboard.
IP Access List
tab.Allow Access From Anywhere
. In this way Wix servers will be able to access your database (also any other device!!).Developer Tools -> Secrets Manager
WeivDataURIs
."{
"visitor": "<visitor-uri>",
"member": "<member-uri>",
"admin": "<admin-uri>"
}"
WeivOwnerID
. This collection will be used to get visitor ids when you enable it for each operation.weiv-data
library. Install @exweiv/weiv-data
package from NPM.WeivData
in your backend section of your site. (backend/WeivData)connection-options.js
, data.js
and config.js
. These are required even if you don't set any data hooks, config settings or custom connection options.backend/
├── WeivData/
│ ├── connection-options.js
│ ├── data.js
│ └── config.js
└──
In WeivData you can configure some settings via config.js
file. All you need to do is export an object and name it as config
, as an example:
export const config = {
defaultIdType: "String",
syncDatabase: "MyDBName",
defaultDatabaseName: "ExWeiv"
};
That config will be used by the library to customize or setup some setting/features in the library for you.
There are not very much to do with security side when you use MongoDB Atlas since it's already managed by MongoDB they will handle the most of the security features. But you should be careful about these steps:
And you should be fine in most cases.
WeivData is already checking things like data types or prototype pollution and throws errors in some cases where you send wrong data. But always follow the secure coding practices.
Just like in WixData you can also define data hooks in WeivData too, hooks will make it possible for you to manipulate the data on the fly that's sent to MongoDB or data returned by the function. There are more hooks in WeivData because WeivData has more functions than WixData and you can learn about these in the documentation of WeivData.
You will use data.js
file inside backend/WeivData
folder. You can define your hooks inside there.
Ask for help, give feedback or anything else? info@apps.exweiv.com
API Reference
Install - NPM
Changelog