How to use cormo - 10 common examples

To help you get started, we’ve selected a few cormo examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github croquiscom / cormo / packages / graphql / src / schema.ts View on Github external
function getGraphQlType(property: typeof cormo.BaseModel['_schema']['path']) {
  let graphql_type: GraphQLScalarType | undefined;
  if (property.record_id) {
    return new GraphQLNonNull(GraphQLID);
  } else if (property.type_class === cormo.types.Number) {
    graphql_type = GraphQLFloat;
  } else if (property.type_class === cormo.types.Integer) {
    graphql_type = GraphQLInt;
  } else if (property.type_class === cormo.types.String) {
    graphql_type = GraphQLString;
  } else if (property.type_class === cormo.types.Text) {
    graphql_type = GraphQLString;
  } else if (property.type_class === cormo.types.Date) {
    graphql_type = CrTimestamp;
  } else if (property.type_class === cormo.types.Object) {
    graphql_type = CrJson;
  }
  if (graphql_type && property.required) {
    return new GraphQLNonNull(graphql_type);
  }
  return graphql_type;
}
github croquiscom / cormo / packages / graphql / src / schema.ts View on Github external
function getGraphQlType(property: typeof cormo.BaseModel['_schema']['path']) {
  let graphql_type: GraphQLScalarType | undefined;
  if (property.record_id) {
    return new GraphQLNonNull(GraphQLID);
  } else if (property.type_class === cormo.types.Number) {
    graphql_type = GraphQLFloat;
  } else if (property.type_class === cormo.types.Integer) {
    graphql_type = GraphQLInt;
  } else if (property.type_class === cormo.types.String) {
    graphql_type = GraphQLString;
  } else if (property.type_class === cormo.types.Text) {
    graphql_type = GraphQLString;
  } else if (property.type_class === cormo.types.Date) {
    graphql_type = CrTimestamp;
  } else if (property.type_class === cormo.types.Object) {
    graphql_type = CrJson;
  }
  if (graphql_type && property.required) {
    return new GraphQLNonNull(graphql_type);
  }
  return graphql_type;
}
github croquiscom / cormo / packages / graphql / src / schema.ts View on Github external
function getGraphQlType(property: typeof cormo.BaseModel['_schema']['path']) {
  let graphql_type: GraphQLScalarType | undefined;
  if (property.record_id) {
    return new GraphQLNonNull(GraphQLID);
  } else if (property.type_class === cormo.types.Number) {
    graphql_type = GraphQLFloat;
  } else if (property.type_class === cormo.types.Integer) {
    graphql_type = GraphQLInt;
  } else if (property.type_class === cormo.types.String) {
    graphql_type = GraphQLString;
  } else if (property.type_class === cormo.types.Text) {
    graphql_type = GraphQLString;
  } else if (property.type_class === cormo.types.Date) {
    graphql_type = CrTimestamp;
  } else if (property.type_class === cormo.types.Object) {
    graphql_type = CrJson;
  }
  if (graphql_type && property.required) {
    return new GraphQLNonNull(graphql_type);
  }
  return graphql_type;
}
github croquiscom / cormo / packages / graphql / src / schema.ts View on Github external
function getGraphQlType(property: typeof cormo.BaseModel['_schema']['path']) {
  let graphql_type: GraphQLScalarType | undefined;
  if (property.record_id) {
    return new GraphQLNonNull(GraphQLID);
  } else if (property.type_class === cormo.types.Number) {
    graphql_type = GraphQLFloat;
  } else if (property.type_class === cormo.types.Integer) {
    graphql_type = GraphQLInt;
  } else if (property.type_class === cormo.types.String) {
    graphql_type = GraphQLString;
  } else if (property.type_class === cormo.types.Text) {
    graphql_type = GraphQLString;
  } else if (property.type_class === cormo.types.Date) {
    graphql_type = CrTimestamp;
  } else if (property.type_class === cormo.types.Object) {
    graphql_type = CrJson;
  }
  if (graphql_type && property.required) {
    return new GraphQLNonNull(graphql_type);
  }
  return graphql_type;
}
github croquiscom / cormo / packages / graphql / src / schema.ts View on Github external
function getGraphQlType(property: typeof cormo.BaseModel['_schema']['path']) {
  let graphql_type: GraphQLScalarType | undefined;
  if (property.record_id) {
    return new GraphQLNonNull(GraphQLID);
  } else if (property.type_class === cormo.types.Number) {
    graphql_type = GraphQLFloat;
  } else if (property.type_class === cormo.types.Integer) {
    graphql_type = GraphQLInt;
  } else if (property.type_class === cormo.types.String) {
    graphql_type = GraphQLString;
  } else if (property.type_class === cormo.types.Text) {
    graphql_type = GraphQLString;
  } else if (property.type_class === cormo.types.Date) {
    graphql_type = CrTimestamp;
  } else if (property.type_class === cormo.types.Object) {
    graphql_type = CrJson;
  }
  if (graphql_type && property.required) {
    return new GraphQLNonNull(graphql_type);
  }
  return graphql_type;
}
github croquiscom / cormo / packages / graphql / src / schema.ts View on Github external
function getGraphQlType(property: typeof cormo.BaseModel['_schema']['path']) {
  let graphql_type: GraphQLScalarType | undefined;
  if (property.record_id) {
    return new GraphQLNonNull(GraphQLID);
  } else if (property.type_class === cormo.types.Number) {
    graphql_type = GraphQLFloat;
  } else if (property.type_class === cormo.types.Integer) {
    graphql_type = GraphQLInt;
  } else if (property.type_class === cormo.types.String) {
    graphql_type = GraphQLString;
  } else if (property.type_class === cormo.types.Text) {
    graphql_type = GraphQLString;
  } else if (property.type_class === cormo.types.Date) {
    graphql_type = CrTimestamp;
  } else if (property.type_class === cormo.types.Object) {
    graphql_type = CrJson;
  }
  if (graphql_type && property.required) {
    return new GraphQLNonNull(graphql_type);
  }
  return graphql_type;
github croquiscom / cormo / packages / graphql / src / schema.ts View on Github external
function buildListQueryArgs(model_class: typeof cormo.BaseModel, options: IOptions) {
  const list_query_args: GraphQLFieldConfigArgumentMap = {
  };
  for (const [column, property] of Object.entries(model_class._schema)) {
    if (column === 'id') {
      list_query_args[column + '_list'] = {
        type: new GraphQLList(new GraphQLNonNull(GraphQLID)),
      };
    } else if (property.record_id) {
      list_query_args[column] = {
        type: GraphQLID,
      };
    } else if (property.type_class === cormo.types.String || property.type_class === cormo.types.Text) {
      list_query_args[column] = {
        type: GraphQLString,
      };
      list_query_args[column + '_istartswith'] = {
        type: GraphQLString,
      };
      list_query_args[column + '_icontains'] = {
        type: GraphQLString,
      };
    } else if (property.type_class === cormo.types.Integer) {
      list_query_args[column] = {
        type: GraphQLInt,
      };
      list_query_args[column + '_gte'] = {
        type: GraphQLInt,
      };
github croquiscom / cormo / packages / graphql / src / decorators.ts View on Github external
export function Column(options: {
  enum?: any, type?: cormo.types.ColumnType
  | cormo.types.ColumnType[],
} & IColumnBasicOptions): PropertyDecorator {
  let cormo_type: cormo.types.ColumnType | cormo.types.ColumnType[];
  if (options.enum) {
    cormo_type = cormo.types.Integer;
  } else {
    cormo_type = options.type!;
  }
  const c = cormo.Column({
    _graphql: {
      description: options.description,
    },
    default_value: options.default_value,
    name: options.name,
    required: options.required,
    type: cormo_type,
    unique: options.unique,
  });
  return (target: object, propertyKey: string | symbol) => {
    c(target, propertyKey);
  };
github croquiscom / graphql-project-sample / services / user / app / models / index.ts View on Github external
import 'reflect-metadata';

import * as cormo from 'cormo';

cormo.BaseModel.lean_query = true;

import { connection_user } from './connection_user';
export { connection_user };

export * from './User';

export async function checkSchemas() {
  if (await connection_user.isApplyingSchemasNecessary()) {
    throw new Error(`need to migrate: run 'npm run migrate'`);
  }
}

export async function applySchemas(verbose = false) {
  await connection_user.applySchemas({ verbose });
}
github croquiscom / cormo / packages / graphql / src / decorators.ts View on Github external
export function BelongsTo(options: IBelongsToBasicOptions) {
  const c_options = {
    foreign_key: options.foreign_key,
    required: options.required,
    type: options.type,
  };
  const c = cormo.BelongsTo(c_options);
  return (target: cormo.BaseModel, propertyKey: string) => {
    c(target, propertyKey);
  };
}

cormo

ORM framework for Node.js

MIT
Latest version published 2 days ago

Package Health Score

69 / 100
Full package analysis