Table of Contents

Working With Objects

Danielle Kellogg Updated by Danielle Kellogg

About Objects

Knack uses objects and fields to define your data.

Objects are used to separate your data into common groups. You can think of an object like a spreadsheet or a database table.

Fields are used to define specific attributes of an object. Think of a field as a spreadsheet column. You'll want to add a field for each attribute you want to store for a given object.

You access your objects by clicking on the "Schema" link in the top left of your Builder:

Your app’s objects are listed in the Schema section of the Builder on the left. Click an object to access the object settings.

What Should My Objects Be?

For most apps, figuring out what the objects are is fairly straightforward. But for cases when it’s less clear, here are some good ways to think about your objects:

  • Consider your fields. It can help by starting at the bottom. List all the fields your app will need to display and manage, then group them into the most logical collections. These collections are your objects.
  • Think about your pages. If you're adding forms, what inputs will those forms contain? If you want to display a table of records, what will the columns be? Ask yourself if each of the inputs or columns sound like they belong to the same group. If not, you will want to store them in separate objects.
  • Singular or plural? If you have data that can be plural combined with data that is singular, then you may want to break up the plural aspects into a separate object. For example, let's say you want to track job applications (single), but each application can have a job history of previous jobs (plural). In this case, it makes sense to make the previous jobs a separate object that would connect to the application object.
  • Do you have repeating data? If you are repeating the same information over and over again in your records, you may want to separate that info into its own object and connect it to your original records instead. This way you will only have to update it once.

Add Objects

Add an object by clicking the green plus button at the top of the toolbox on the left side of the Builder:

This will bring up a pop-up to add your object with tabs for 3 options.

  • From Scratch
  • By Import
  • By Template

Add an Object From Scratch

This tab lets you add your object from scratch:

This means you'll need to add all the object’s fields yourself. This is the most common way to add an object if you are not starting with an existing spreadsheet.

First, give your object a name. We recommend you use the plural version of your object name (e.g. Companies instead of Company). Knack automatically creates a singular version and will use the right version when needed.

Click the "Add Object" button and your new object will be saved and added. You can now start adding fields to this new object. A default "Name" field (e.g. Company Name) is added automatically.

Add an Object by Import

If you are starting with an existing spreadsheet, click the "Import a Spreadsheet" tab:

Knack will create a field for each column in the spreadsheet (or each column you choose to add) and import each record into the object.

Click here to learn more about importing spreadsheets.

Add an Object by Template

Click on the “By Template” tab to select from common object templates:

All the fields listed for each template will be added to your new object. You're free to update, delete or add new fields after the object is added.

Edit Objects

To edit an object select the “more options” menu (the “...” icon) next to the object's name. Then select the "Settings" option. Here you will be able to edit the name, display field, and default sort order of that object.

Rename Object: The name of the object used throughout the Builder.

Set Display Field: The display field is the field that represents this object. This field is used throughout the application when these records are displayed in connection fields for this object. By default, this will be the first field in the object.

Make sure the identifying field is something that is easily recognizable, like a name field. Auto Increment fields and ID fields are not usually good options since you are less likely to know a record by its numerical code.

Set Default Sort Order: The default sort order is used to order the records when no other sort order is given. This defaults to the order the record was added, but you can set it to sort by any field.

Object sorting preferences do not apply to records displayed in a view in any manner. Sorting on an object only applies to record sorting in the Builder and for dropdowns used with this object in a connection field. 

Copy Objects/Fields

An object and its fields can be copied by clicking on the more options menu (the “...” icon) next to the object’s name and selecting the "Copy" option:

You'll be given the option to copy the fields to either a new or existing object.

If you choose a new object, you'll be asked to name the new object. If you choose an existing object, you will be asked to select which existing object. Then you can select which fields to copy:

When copying a User Role object to another existing User Role object, be sure to NOT copy the five user required fields: Name, Email, Password, User Status and User Roles. If you do, you will find that you are unable to delete the duplicate fields since they are required. 
Records on an object are not copied. If the original records are needed on the copied object, this will require exporting the records from the original object into the copied object.

Connect Objects Together

The right column lists any connections the object has and a green plus button to add a new connection:

When you add a new connection it creates a special connection field in that object.

These fields can be used like any other field throughout your app. If you add a connection field to a form, it will operate like a "look-up," where you can select a record to connect to from the connected object.

Connections open up powerful functionality, such as:

Click here to learn more about what is possible using connections.

Object Records

Above the list of fields in the Schema section, you can select the database icon which will show you all the records stored in this object. This can also be accessed for all objects on the “Records” tab from the left-hand menu.

Click here for more on managing records.

Delete Objects

You can delete an object by clicking on the more options  (the "..." icon) next to the object’s name and selecting the Delete option:

You'll be asked to confirm this action.

Deleting an object is destructive. Deleting an object will remove that object entirely, including any records and wherever it may be used in your live application. If you have any views displaying records from that object, those views will be removed as well.

How did we do?

Plan Your Connections: Complex Example

About Connections

Contact