How to manage multiple JSON schema files?

In JSON Schemas, you can either put a schema per file and then access them using their URL (where you stored them), or a big schema with id tags. Here is for one big file: { “id”: “#root”, “properties”: { “author”: { “id”: “#author”, “properties”: { “first_name”: { “type”: “string” }, “last_name”: { “type”: “string” … Read more

Using RegEx in JSON Schema

To test a string value (not a property name) against a RegEx, you should use the “pattern” keyword: { “type”: “object”, “properties”: { “progBinaryName”: { “type”: “string”, “pattern”: “^[A-Za-z0-9 -_]+_Prog\\.(exe|EXE)$” } } } P.S. – if you want the pattern to match the key for the property (not the value), then you should use “patternProperties” … Read more

How should I visualize the structure of my code? [closed]

I tried using a number of UML tools and found that the reverse-engineering capabilities in most UML tools were not helpful for understanding code. They focus on designing needs and reverse-engineering capabilities often just ends up showing huge pictures of lots of useless information. When I was working on the Microsoft Office codebase, I found … Read more

How to extend a schema in JSON schema?

JSON Schema doesn’t use an object oriented paradigm, so concepts like inheritance don’t translate well. JSON Schema is a collection of constraints. It’s subtractive rather than additive like most people are used to. This means that given an empty schema, the set of valid JSON documents is the set of all JSON documents. As you … Read more

Creating a multi-tenant application using PostgreSQL’s schemas and Rails

Update Dec 5, 2011 Thanks to Brad Robertson and his team, there’s the Apartment gem. It’s very useful and does a lot of the heavy lifting. However, if you’ll be tinkering with schemas, I strongly suggest knowing how it actually works. Familiarize yourself with Jerod Santo’s walkthrough , so you’ll know what the Apartment gem … Read more

Execute .sql schema in psycopg2 in Python

You can just use execute: with self.connection as cursor: cursor.execute(open(“schema.sql”, “r”).read()) though you may want to set psycopg2 to autocommit mode first so you can use the script’s own transaction management. It’d be nice if psycopg2 offered a smarter mode where it read the file in a statement-at-a-time and sent it to the DB, but … Read more

How to join query in mongodb?

To have everything with just one query using the $lookup feature of the aggregation framework, try this : db.User.aggregate( [ // First step is to extract the “friends” field to work with the values { $unwind: “$friends” }, // Lookup all the linked friends from the User collection { $lookup: { from: “User”, localField: “friends”, … Read more