A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://frederikbache.github.io/vue-vroom/guide/models/ below:

Website Navigation


Creating models | Vue goes Vroom

Creating models # Schema #

A models schema is an object of fields you want to exist on your model. Each field should have a type which should be a function that returns the type you want.

It can be built-in constructors e.g. String, Number or Boolean or you can cast more complex types yourself

Each field can also take an optional: true, that will signify that this prop might not always be returned from the api.

typescript
type Coordinate = {
  lat: Number;
  lon: Number;
};

const mountain = defineModel({
  schema: {
    name: { type: String },
    elevation: { type: Number },
    coordinates: { type: Object as () => Coordinate },
    rank: { type: Number, optional: true },
  },
});

The resulting types will be


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4