Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@travetto/model

Package Overview
Dependencies
Maintainers
1
Versions
371
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@travetto/model - npm Package Compare versions

Comparing version 0.1.8 to 0.2.0

e2e/index.js

11

package.json

@@ -7,9 +7,12 @@ {

"dependencies": {
"@travetto/di": "^0.1.6",
"@travetto/schema": "^0.1.8"
"@travetto/di": "^0.2.0",
"@travetto/schema": "^0.2.0"
},
"description": "Datastore abstraction for CRUD operations with advanced query support.",
"devDependencies": {
"@travetto/test": "^0.1.6"
"@travetto/test": "^0.2.0"
},
"optionalExtensionDependencies": {
"@travetto/express": "^0.1.11"
},
"homepage": "https://travetto.io",

@@ -33,3 +36,3 @@ "keywords": [

},
"version": "0.1.8"
"version": "0.2.0"
}

@@ -106,2 +106,52 @@ travetto: Model

This would find all users who are over 35 and that have the `contact` field specified.
This would find all users who are over 35 and that have the `contact` field specified.
## Extensions
Integration with other modules can be supported by extensions. The dependencies are `optionalExtensionDependencies` and must be installed directly if you want to use them:
### Express
[`Express`](https://github.com/travetto/express) support with the `@ModelController` for exposing common RESTful patterns for routes.
```typescript
@ModelController('/user', User)
class UserController {
source: ModelService;
}
```
is a shorthand that is equal to:
```typescript
@Controller('/user')
class UserController {
source: ModelService;
@Get('')
async getAllUser(req:Request) {
return await this.source.getAllByQuery(User, JSON.parse(req.params.q));
}
@Get(':id')
async getUser(req:Request) {
return await this.source.getById(User, req.params.id);
}
@Delete(':id')
async deleteUser(req:Request) {
return await this.source.deleteById(User, req.params.id);
}
@Post('')
@SchemaBody(User)
async saveUser(req:TypedBody<User>) {
return await this.source.save(User, req.body);
}
@Put('')
@SchemaBody(User)
async updateUser(req:TypedBody<User>) {
return await this.source.update(User, req.body);
}
}
```
import { Class } from '@travetto/registry';
import { ModelRegistry, IndexConfig } from '../service';
import { ModelRegistry } from '../service';
import { IndexConfig } from '../types';

@@ -4,0 +5,0 @@ function createIndex<T extends Class>(target: T, config: IndexConfig<T>) {

import { Class } from '@travetto/registry';
import { ModelRegistry, ModelOptions } from '../service';
import { ModelRegistry } from '../service';
import { ModelOptions } from '../types';

@@ -4,0 +5,0 @@ export function Model(conf: Partial<ModelOptions<any>> = {}) {

export * from './decorator';
export * from './model';
export * from './service';
export * from './service';
export * from './types';

@@ -0,5 +1,5 @@

import { Class } from '@travetto/registry';
import { Schema } from '@travetto/schema';
import { ModelCore } from './model';
import { ModelRegistry } from '../service';
import { Class } from '@travetto/registry';

@@ -6,0 +6,0 @@ @Schema()

export * from './model';
export * from './types';
export * from './registry';
export * from './source';
export * from './class-model';
import { Class } from '@travetto/registry';
import { BindUtil, SchemaValidator, DEFAULT_VIEW } from '@travetto/schema';
import { Injectable } from '@travetto/di';
import { Env, Util } from '@travetto/base';
import { QueryVerifierService } from './query';
import { Injectable } from '@travetto/di';
import { ModelOptions } from './types';
import { ModelOptions } from '../types';
import { ModelCore, Query, BulkState, ModelQuery, PageableModelQuery } from '../model';

@@ -10,4 +12,2 @@ import { ModelSource } from './source';

import { Env, Util } from '@travetto/base';
function getClass<T>(o: T) {

@@ -14,0 +14,0 @@ return o.constructor as Class<T>;

@@ -1,7 +0,8 @@

import { ModelQuery, Query, PageableModelQuery } from '../../model';
import { Class } from '@travetto/registry';
import { SimpleType, ErrorCollector, OPERATORS, TypeUtil } from './types';
import { SchemaRegistry } from '@travetto/schema';
import { Injectable } from '@travetto/di';
import { Util } from '@travetto/base';
import { ModelQuery, Query, PageableModelQuery } from '../../model';
import { SimpleType, ErrorCollector, OPERATORS, TypeUtil } from './types';
import { ValidationErrors } from './error';

@@ -8,0 +9,0 @@

@@ -5,3 +5,3 @@ import { SchemaRegistry, SchemaChangeEvent } from '@travetto/schema';

import { ModelOptions } from './types';
import { ModelOptions } from '../types';

@@ -8,0 +8,0 @@ export class $ModelRegistry extends MetadataRegistry<ModelOptions<any>> {

{
"compilerOptions": {
"module": "commonjs",
"target": "es2017",
"target": "es2018",
"strict": true,

@@ -6,0 +6,0 @@ "noStrictGenericChecks": true,

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc