Comments (10)
There is no official offline/local-first data handling for now.
PocketBase v0.9+ supports writing external migrations with JS (more documentation on that will be available soon).
It also comes with automigrate functionality, aka. when doing collection changes in the UI or via the web APIs it will automatically generate a js/go migration file inside pb_migrations
that you can commit to your repo. Migrations are executed automatically on server start (aka. ./pocketbase serve
).
I'm not sure that I understand your use case, but you can use the pb.collections.*
apis (you'll have to be authenticated as admin in order to be able to modify the collections) since they will trigger the automigrate functionality.
from dart-sdk.
from dart-sdk.
from dart-sdk.
from dart-sdk.
Can you show us an example of adding a new column to a collection or
removing a column from a collection
Here is an example using the Dart SDK (I haven't tested it, but it should give you an idea of the expected workflow):
final pb = PocketBase("http://127.0.0.1:8090");
final collection = await pb.collections.getOne("uktsrgciaq83ltm"); // id or name
// add a new collection field...
collection.schema.add(SchemaField(
id: "someRandomFieldId", // optional (it will be auto generated if missing)
name: "myNewField",
type: "text",
required: true,
// options differ depending on the field type
// all field types and their options could be found in
// https://pkg.go.dev/github.com/pocketbase/[email protected]/models/schema
// (the `json` value is the body key, for example the date options are https://pkg.go.dev/github.com/pocketbase/[email protected]/models/schema#DateOptions)
options: <String, dynamic>{
"min": 10,
},
));
// remove a field (aka. remove an element from the List)
collection.schema.removeAt(2);
// rename a field (aka. edit an existing List element)
collection.schema[1].unique = false;
// persist changes
await pb.collections.update(collection.id, body: collection.toJson());
About auto migration. Can you please show us an example of how updating or adding of a column work there.
How we can put migrating files in our repo and start a new project with the
same tables
The automigrations are automanaged, aka. when doing collection changes from the Admin UI or via the web API (as in the previous SDK example), it will automatically generate a js migration file for you in the pb_migrations
folder. You can copy this folder to another location and place it next to your pb_data (or if you want to specify a different location, you can also use the --migrationsDir="/path/to/pb_migrations"
flag when starting PocketBase; more info you can find with the --help
flag).
When we ship a new version of our application adding columns or renaming
column shall be done automatically
I'm not sure what to recommend. As mentioned, for now offline/local-first data handling is not supported out of the box and this require some manual management from the developer side. I don't think there is a single generic solution for this since it really depends on your use case and the desired deployment flow, eg. how you are connecting to the remote server, how you are planning to propagate and sync changes, how you are planning to handle schema conflicts (eg. the user locally created a column with the same name but different id as your new remote update), etc.
from dart-sdk.
from dart-sdk.
from dart-sdk.
Sorry, currently only Go and JS (via goja, an embedded go js runtime) migrations are supported and there are no plans for adding support for Dart since it will be too difficult and time consuming to maintain, document and test.
from dart-sdk.
And about sync: are there any plan to add offline first then sync to server feature?
from dart-sdk.
Offline/local-first data handling is in my todo to research it but for now is a very low priority and it is not planned for the near future.
from dart-sdk.
Related Issues (20)
- android app auth data HOT 2
- Issue with filtering in dart-sdk HOT 1
- Dart suggestion code should not contain quotes HOT 1
- Bug: authStore did not save token and model. HOT 1
- Can't create new user with OAuth (404 from PB) HOT 2
- How to close browser with successful oauth using authWithOAuth2? HOT 7
- how to yield from subscription function HOT 4
- Upgrade http to 1.0.0 HOT 3
- Flutter pocketbase db 501 error HOT 17
- Need info HOT 1
- Add a RecordModel.getMapValue() method HOT 3
- can't reach the server from flutter when running in real android device HOT 1
- Discord OAuth Issue HOT 6
- Streamline requests' _jsonRequest and _multipartRequest body HOT 1
- Username/Password authentication from Flutter Web HOT 10
- How to filter the expanded items only HOT 2
- I cant add pocketbase dependency in my flutter project. How to fix? HOT 1
- Weird create function with body and files in Dart SDK HOT 2
- make models `RecordModel|AdminModel|null` use a base type `BaseModel` to avoid use of `dynamic` HOT 1
- missed argument collection name inside buildUrl() HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dart-sdk.