func (m *Module) Create(ctx context.Context, dbAlias, col string, req *model.CreateRequest, params model.RequestParams) error {
	m.RLock()
	defer m.RUnlock()
	dbType, err := m.getDBType(dbAlias)
	if err != nil {
		return err
	}
	if err := schemaHelpers.ValidateCreateOperation(ctx, dbAlias, dbType, col, m.schemaDoc, req); err != nil {
		return err
	}
	params.Payload = req
	hookResponse := m.integrationMan.InvokeHook(ctx, params)
	if hookResponse.CheckResponse() {
		if err := hookResponse.Error(); err != nil {
			return err
		}
		return nil
	}
	crud, err := m.getCrudBlock(dbAlias)
	if err != nil {
		return err
	}
	if err := crud.IsClientSafe(ctx); err != nil {
		return err
	}
	var n int64
	if req.IsBatch {
		n, err = m.createBatch(ctx, m.project, dbAlias, col, req.Document)
	} else {
		n, err = crud.Create(ctx, col, req)
	}
	if err == nil {
		m.metricHook(m.project, dbAlias, col, n, model.Create)
	}
	return err
}
Create inserts a documents (or multiple when op is "all") into the database based on dbType
package crud
import (
	"context"
	"fmt"
	"github.com/spaceuptech/helpers"
	"github.com/spaceuptech/space-cloud/gateway/model"
	schemaHelpers "github.com/spaceuptech/space-cloud/gateway/modules/schema/helpers"
	"github.com/spaceuptech/space-cloud/gateway/utils"
)