Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 82475

Node library implementation

$
0
0

Hi Allan

We are implementing editor with nodejs. The current versions that we are using are:

Nodejs: 9.5
knex: 1.4

We had installed datatables.net-editor-server from npm repositorys

The code of node is next

layer service

import db from '../../models/db';
const DBTABLE = 'schema.table_name'; 
import {
    Editor,
    Field,
    Validate,
    Format,
    Options
}  from 'datatables.net-editor-server';


        async proccessAll(req, eliminado=false) {
            try {
                let editor = new Editor(db, DBTABLE).fields(
                    new Field('arl_nombre'),
                    new Field('arl_tipo'),
                    new Field('arl_vigente'),
                    new Field('arl_defecto')
                );
                return await editor.process(req.body);                
            } catch (error) {
                throw error;
            }
        };

layer conrtoller

router.all('/proccess', async (req, res, next) => {
    try {
        //procesando la información...
        const editor = await aerService.proccessAll(req);
        //retornando...
        res.status(200).json(editor.data());        
    } catch (error) {
        res.status(400).json({
            error: error.message
        });
    }
});

Is the exactly the examples of Node documentation, but, always we have this message: Cannot convert undefined or null to object

Please, can yoy help us?

Thanks a lot for you support


Viewing all articles
Browse latest Browse all 82475

Trending Articles