Skip to content
This repository was archived by the owner on Mar 10, 2026. It is now read-only.

Repository files navigation

condor-mongoose

This module allows you to create CRUD services over GRPC in less than 5 minutes.

Build StatusCoverage Status

How to use (Summary)

  • Just define your protos, and your mongoose models.
  • Setup your service using condor-framework and extending the CrudBaseService class.
  • Voilá, you have a working CRUD service over gRPC, connected to mongo (using mongoose).

Features

  • Automatic CRUD generation (list, insert, update, get, delete)
  • Supports subdocuments and related models
  • Allows queries (where, fields, limit, skip, sort)
  • Allows automatic population of related models (populate)

Installation

npm i --save condor-framework mongoose condor-mongoose

How to use

  1. Define the proto file.
syntax="proto3";
packagebussiness;
messageWhere {
stringfield=1;
stringvalue=2;
Matchermatcher=3;
}
messageSort {
stringfield=1;
int32value=2;
}
enumMatcher {
STRING=0;
REGEX=1;
OBJECT=2;
}
messageQueryRequest {
repeatedWherewhere=1; // empty => allrepeatedstringfields=2; // empty => allint32limit=3; // 0 => unlimitedint32skip=4; // 0 => nonerepeatedSortsort=5;
}
messagePersonUpdate {
stringid=1;
repeatedstringfields=2;
Persondata=3;
}
messageEmpty {}
messageIdRequest {
stringid=1;
}
messagePerson {
stringid=1;
stringname=2;
int32age=3;
}
servicePersonsService {
rpcList (QueryRequest) returns (Person) {}
rpcInsert (Person) returns (Person) {}
rpcUpdate (PersonUpdate) returns (Person) {}
rpcGet (IdRequest) returns (Person) {}
rpcDelete (IdRequest) returns (Empty) {}
}
  1. Create a service that extends from CrudBaseService.
constCrudBaseService=require('condor-mongoose');constmongoose=require('mongoose');constpersonSchema={'name': String,'age': Number,};constPerson=mongoose.model('Person',newmongoose.Schema(personSchema));module.exports=classextendsCrudBaseService{constructor(){super(Person);}};

Note:CrudBaseService contains base methods (insert, update, delete, get, list), sub documents methods (push, addToSet, remove, update and replace) and related models methods (push, addToSet, remove and replace).

  1. Initialize the service.
constmongoose=require('mongoose');constCondor=require('condor-framework');constPromise=require('bluebird');constPersonService=require('./models/personService');mongoose.Promise=Promise;mongoose.connect('mongodb://localhost/business');constprotoPath='./bussiness.proto';condor=newCondor().addService(protoPath,'business.PersonService',newPersonService()).start();

License and Credits

MIT License. Copyright 2017 Devsu LLC, a great node development team

About

Utils to work with mongoose and condor GRPC framework

Topics

Resources

Stars

7 stars

Watchers

6 watching

Forks

Releases

Packages

Used by

Contributors

Languages