How to use the cormo.types function in cormo

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

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);
  };

cormo

ORM framework for Node.js

MIT
Latest version published 23 days ago

Package Health Score

70 / 100
Full package analysis